Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 5 down vote accepted
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

enter image description here

share|improve this answer
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 :)

share|improve this answer
I don't know what is the term normalize and how can i do it? plz help. – kandarp Sep 7 '11 at 9:17 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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.