Point on a line
Hi
How can I find out if a point is on a line.
Like this. How can I check if a point lie above or below?
here is a not accurate picture.
The point is not accurate, I have just placed it on the side.
I need the formula.
This will be used to calculate the ILS(Instrument Landing System) approch on an airport.
Thanks, Fredrik
[Edited by - fredrik90 on October 13, 2005 11:58:58 AM]
just formulate your "Geraden-Gleichung" I don't the english word:
first take your start point:
(2;2) so this means 2 = a * 2 + b => b = 2(1-a)
than take the second point
(4;5) 5 = a * 4 + b => 5 = a * 4 + 2 - 2 * a => 5 = 2*a+2 => a = 1,5
=> back to one
b = -1
so than you have your result, each point on your line must solve the equatiton
y = 1.5 * x - 1
first take your start point:
(2;2) so this means 2 = a * 2 + b => b = 2(1-a)
than take the second point
(4;5) 5 = a * 4 + b => 5 = a * 4 + 2 - 2 * a => 5 = 2*a+2 => a = 1,5
=> back to one
b = -1
so than you have your result, each point on your line must solve the equatiton
y = 1.5 * x - 1
i can write some code if you like but i need to know what format the line is in (equation, two points, one point + angle?).
the line is 2 points with 3 vertex on each. like (45, 200, 100) and (45, 0, 1)
this is just examples.
this is just examples.
Take it easy!
In 2D, you only need to know how much is the angle between the point and the line.
Think about cosines and cross product, your problem would define as:
Point:
P = {x,y}
Line(two points:
L1 = {x1,y1}
L2 = {x2,y2}
So:
V1 = P - L1 = {x-x1,y-y1} = {vx1,vy1}
V2 = L2 - L1 = {x2-x1,y2-y1} = {vx2,vy2}
Cross product:
c = V1%V2 = vx1*vy2 - vy1*vx2
If c = 0 then the point is on the line.
In 2D, you only need to know how much is the angle between the point and the line.
Think about cosines and cross product, your problem would define as:
Point:
P = {x,y}
Line(two points:
L1 = {x1,y1}
L2 = {x2,y2}
So:
V1 = P - L1 = {x-x1,y-y1} = {vx1,vy1}
V2 = L2 - L1 = {x2-x1,y2-y1} = {vx2,vy2}
Cross product:
c = V1%V2 = vx1*vy2 - vy1*vx2
If c = 0 then the point is on the line.
I did forgive this:
if c>0 then the point is above of the line.
And if c<0 then the point is under the line.
Cheers.
if c>0 then the point is above of the line.
And if c<0 then the point is under the line.
Cheers.
Yes! of course.
The same thing extends to 3D.
Point:
P = {x,y,z}
Line(two points:
L1 = {x1,y1,z1}
L2 = {x2,y2,z2}
So:
V1 = P - L1 = {vx1,vy1,vz1}
V2 = L2 - L1 = {vx2,vy2,vz2}
Cross product:
C = V1.cross(V2) = {vy1*vz2 - vz1*vy2,
-(vx1*vz2 - vz1*vx2),
vx1*vy2 - vy1*vx2)}
So |C| = sin(r)*|V1||V2|, where r is the angle between vectors.
If the length of C is 0, then the point is on the line. It can be verify as:
C.x*C.x + C.y*C.y + C.z*C.z == 0.0
Hope It help you.
The same thing extends to 3D.
Point:
P = {x,y,z}
Line(two points:
L1 = {x1,y1,z1}
L2 = {x2,y2,z2}
So:
V1 = P - L1 = {vx1,vy1,vz1}
V2 = L2 - L1 = {vx2,vy2,vz2}
Cross product:
C = V1.cross(V2) = {vy1*vz2 - vz1*vy2,
-(vx1*vz2 - vz1*vx2),
vx1*vy2 - vy1*vx2)}
So |C| = sin(r)*|V1||V2|, where r is the angle between vectors.
If the length of C is 0, then the point is on the line. It can be verify as:
C.x*C.x + C.y*C.y + C.z*C.z == 0.0
Hope It help you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement