How to find the midpoint of the segment?