AB is a segment defines by the two points A and B.
Say the coordinates of the point A are (a1, a2) and the coordinates of point B are (b1,b2).
The midpoint is found using this.
x = (a1+b1)/2 and y = (a2+b2)/2
So, the coordinates of the midpoint are (a1+b1)/2 , (a2,b2)/2.
With that you can solve your question known the coordinates of points A and B.