# Thread: Calculating coords of a point on a straight line at a distance from start point...

1. ## Calculating coords of a point on a straight line at a distance from start point...

Hi,

I have a straight line whose start and end points are known. (Pt1 and Pt2)...

Is it possible to calculate the coordinates of a point that is on on this straight line at a distance of 1000 from pt1 or pt2...

thanks

2. Originally Posted by ayrus
Hi,

I have a straight line whose start and end points are known. (Pt1 and Pt2)...

Is it possible to calculate the coordinates of a point that is on on this straight line at a distance of 1000 from pt1 or pt2...

thanks
yes...

use the distance formula. for the y-coordinate, plug in the equation of the line

3. Originally Posted by Jhevon
yes...

use the distance formula. for the y-coordinate, plug in the equation of the line
Hi jhevon,

I need to write a program what could calculate the values as described in the topic...

If I were to calculate,

Distance Formula: Dist ^2 = (y2-y1)^2 + (x2-x1)^2
and substituting y=mx+c in the above equation...

This looks little tedious programmatically; I am wondering if there are any alternate ways of solving the problem...

thanks

4. Suppose that P(a,b) & Q(c,d) are the end points of the line segments.
Define $D = \sqrt {\left( {a - c} \right)^2 + \left( {b - d} \right)^2 }$.
Now define $l(t) = \left( {a + t\frac{{c - a}}{D},b + t\frac{{d - b}}{D}} \right)\quad ,t \in \mathbb{R}$, equation of the line determined by P & Q.
Note that $l(D) = Q$ so that $l(1000)$ is the point 1000 units from P in the Q direction.
Whereas $l(-1000)$ is the point 1000 units from P in the direction opposite of Q (that is P is between that point and Q).
If you need distances from Q then just change the definition of the line.