Finding the coordinates of a point on a line segment