How to calculate the middle of a line?

19.8k Views Asked by At

My question is following. I have a line with a given $(X_1, Y_1)$ and $(X_2, Y_2)$ coordinates (see figure below). I need to calculate coordinates of the middle of this line $(X, Y)$. I tried to use classical method of finding distance between two coordinates, but it works only when the line is situated horizontally.

Could anybody help me with a formula to find coordinates of the middle of a given line please?

Thanks beforehand.

Line

2

There are 2 best solutions below

0
On

You can just average the points: $x = \dfrac{x_1 + x_2}{2}$ $y = \dfrac{y_1 + y_2}{2}$

3
On