# 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

``````P = t * (B-A) + A

Px = t * (Bx-Ax) + Ax
Py = t * (By-Ay) + Ay

Px - Ax   Py - Ay
------- = -------
(Bx-Ax)   (By-Ay)

(By - Ay)
Py = (Px - Ax) * --------- + Ay
(Bx - Ax)

(5 - -1)                   6
Py = (Px - 2) * -------- + -1 = (Px -2) * --- - 1
(4 - 2)                    2

Py = (Px-2)*3 -1 = 3*Px -6 -1 = 3*Px-7
``````

A,B are points in this case A = (2, -1), B=(4,5) P is the point you are lookink for

Ax is the coordinate x of point A.... in this case Ax=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
My dear friend heartly thanks It works nicely. – kandarp Sep 7 '11 at 10:04

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).

//EDIT: Ou. Blau was little faster :)

-
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

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