hi,
I have a line drawn on a grid all i know is start and end co-ords of the line from the start co-ord i need to calculate a point on the line that is just slightly further down the line than the first point. is this possibe?
Printable View
hi,
I have a line drawn on a grid all i know is start and end co-ords of the line from the start co-ord i need to calculate a point on the line that is just slightly further down the line than the first point. is this possibe?
If I understand correctly, you have the coordinates of 2 points that define a line (let's call them x1,y1 and x2,y2) and you want to know the coordinates of a point x,y that is a certain distance d along the line from x1,y1 in the direction of x2,y2. If that's what you are looking for, following methodology applies.
1. The line is at an angle to horizontal. The tangent of the angle (theta) is: tan(theta) = (y2 - y1)/(x2 - x1). Calculate theta
2. The unknown point x,y is a distance d along the line from point x1, y1 in the direction of x2,y2.
x = x1 + d*cos(theta)
y = y1 + d*sin(theta)
Or you can calculate the length of the line L to be sqrt(dx^2 + dy^2), where dx is x2 - x1 and dy is y2-y1. If you are looking for distance l along the line D, then x' = x1+(dx*l/L) and y' = y1+(dy*l/L).
It amounts to the same thing.
zaza