Geometry – How to Find a Point Between Two Points with Given Distance

geometry

Lets say I have point P1(10,10) and P2(20,20).

I want to find a P3 which is on between this two points and 3 units away from P1.

What is the formula to find P3 ?

Known values: X1, X2, Y1 , Y2, distance.

Wanted values: X3, Y3

http://i.imgur.com/EwuiCUJ.png

Best Answer

Here are some hints:

  1. Find the unit vector that points from P1 to P2.
  2. Multiply that vector by $3$ and add it to P1.

In general terms, the unit vector is

$$\hat{u} = \frac{x_2-x_1}{D}\hat{x} + \frac{y_2-y_1}{D}\hat{y},$$

where $\hat{x}, \hat{y}$ are unit vectors in the $x$ and $y$ directions, and $D = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$ is the distance between $P_1$ and $P_2$.

Then, if you're looking for the point a distance $d$ away from $P_1$ along the line through $P_1$ and $P_2$, then, vector-based the answer is

$$\vec{P_3} = \vec{P_1} + d\hat{u}.$$

Splitting up the components gives:

$$x_3 = x_1 + \frac{d}{D}(x_2-x_1)$$

$$y_3 = y_1 + \frac{d}{D}(y_2-y_1).$$