# How can I find a point on a line when I have only two other points?

I have a straight line passing from points A(2,-1) and B(4,5). I want to find a point C that is on the line and outside A-B.

• What is the relation between the first, second and third point? – Roy T. Sep 7 '11 at 9:43
• all 3 should be in straight line – kandarp Sep 7 '11 at 9:47
• This isn't a Game development question, it's a simple math question, sorry. – Cyclops Sep 7 '11 at 12:39

\begin{align} P &= t (B-A) + A \\ P_x &= t (B_x - A_x) + A_x \\ P_y &= t (B_y - A_y) + A_y \\ \end{align} $$\frac {P_x - A_x} {B_x - A_x} = \frac {P_y - A_y} {B_y - A_y}$$ \begin{align} P_y &= (P_x - A_x) \times \frac {B_y - A_y} {B_x - A_x} + A_y \\ &= (P_x - 2) \times \frac {5 - -1} {4 - 2} + -1 \\ &= (P_x - 2) \times \frac 6 2 - 1 \\ &= (P_x - 2) \times 3 - 1 \\ &= 3 \times P_x - 6 - 1 \\ &= 3 \times P_x - 7 \end{align}

$$\A\$$ and $$\B\$$ are points. In this case $$\A\$$ = (2, -1), $$\B\$$ = (4,5) $$\P\$$ is the point you are looking for.

$$\A_x\$$ is the coordinate $$\x\$$ of point $$\A\$$. In this case $$\A_x = 2\$$.

• In first eqn you write P=t * (B-A) and x=t * (Bx-Ax) so what is Bx and Ax? I am unable to understand plz explain. – kandarp Sep 7 '11 at 9:14
• would you tell me how c=2 arrives? – kandarp Sep 7 '11 at 9:53
• I am very close to solution plz explain how c=2 is calculated? – kandarp Sep 7 '11 at 9:58
• i have introduced C to show you visually how can you get a point in a line based on two known points. You can multiply (B-A) by whatever factor "t" and you will get points in that line. – Blau Sep 7 '11 at 10:01

To find points that lay on a line that passes through two known points you use linear interpolation.

• but i don't want to find third point between the two points i want to find the third point outside the two points – kandarp Sep 7 '11 at 9:39
• To do that you just need to pass e.g. t=2 to your interpolation function. – user744 Sep 7 '11 at 16:07

If I understand you right, you have point A on coordinates (2,-1) and B on (4,5). You want to find point C, if you know for example x coordinate?

You can compute direction vector from A to B, which is: B - A = (2, 6), then normalize it, so you get: (1/sqrt(10), 3/sqrt(10)). If you have for example that x coordinate of point C (lets say its for example 8), you divide this by x coordinate of direction vector and multiplz by y coordinate of direction vector. You get: 8 / 1 * 3 = 24. So point C has coordinates (10, 24).

• I don't know what is the term normalize and how can i do it? plz help. – kandarp Sep 7 '11 at 9:17
• en.wikipedia.org/wiki/Unit_vector You just divide each coordinate of vector by length of vector (length = sqrt(xx + yy)) – zacharmarz Sep 7 '11 at 9:40