Point on a line

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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]

Share on other sites

(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

Share on other sites
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?).

Share on other sites
the line is 2 points with 3 vertex on each. like (45, 200, 100) and (45, 0, 1)
this is just examples.

Share on other sites
Take it easy!

In 2D, you only need to know how much is the angle between the point and the line.

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.

Share on other sites
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.

thanks...

Share on other sites
And you need this on 3D too?

Share on other sites
yes... if you have it?

Share on other sites
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

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• Forum Statistics

• Total Topics
633270
• Total Posts
3011157
• Who's Online (See full list)

There are no registered users currently online

×