-5
\$\begingroup\$

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.

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

$$ \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\$.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – kandarp Sep 7 '11 at 9:14
  • \$\begingroup\$ would you tell me how c=2 arrives? \$\endgroup\$ – kandarp Sep 7 '11 at 9:53
  • \$\begingroup\$ I am very close to solution plz explain how c=2 is calculated? \$\endgroup\$ – kandarp Sep 7 '11 at 9:58
  • \$\begingroup\$ 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. \$\endgroup\$ – Blau Sep 7 '11 at 10:01
0
\$\begingroup\$

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

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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