Algorithm for the closest point on a line, to a line

Started by
9 comments, last by skow 20 years, 9 months ago
There are quick and easy ones for a point on a line close to a point. Is there a process for the closest point on a line to a line. I can think of how to do it using recursion, and that is very processor demanding. Can any one think of process for this?
Advertisement
If the line is an axis, it can be done easily using derivative calculus. For an arbitrary line, though, I''m not sure.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

For lines L1 and L2, which pass through points L1a and L1b, and L2a and L2b, respectively:

find vectors for each line.
V1 = L1a - L1b
V2 = L2a - L2b

Take the cross product.

V = V1 x V2

Take an arbitrary point.

Pt0

Take the plane with V as its normal, which passes through Pt0.

P = plane(Pt0, V)

Find the projections of L1 and L2 onto P.

L1'' = proj(L1, P)
L2'' = proj(L2, P)

Find the intersection of the two lines.

Pt = intersect(L1'', L2'')

Take the line passing through Pt that is perpendicular to P.

L = line(Pt, P)

Find the points where L intersects L1 and L2.

Pt1 = intersect(L, L1)
Pt2 = intersect(L, L2)

Those two points are the closest points on the lines.

How appropriate. You fight like a cow.
Sneftel, your a life savor, my eyes were going cross eyed while triing to think it out.
Hmm i cant remember how to project a line onto a plane, and I cant seem to find an example or algorithm on the net...

Could i please get you to post how to project a line onto a plane?
quote:Original post by skow
Hmm i cant remember how to project a line onto a plane, and I cant seem to find an example or algorithm on the net...

Could i please get you to post how to project a line onto a plane?


God, I have no clue..... it''s been forever. I''m no good when it comes to actual equations, rather than geometric procedures. Any takers?

How appropriate. You fight like a cow.
Hmm also i got another question

"Take the line passing through Pt that is perpendicular to P.

L = line(Pt, P)"

If a line is perpendicular to a plane, wouldnt it be a normal. so wouldnt L be the same as V? a normal line from the point?
quote:Original post by skow
Hmm also i got another question

"Take the line passing through Pt that is perpendicular to P.

L = line(Pt, P)"

If a line is perpendicular to a plane, wouldnt it be a normal. so wouldnt L be the same as V? a normal line from the point?


Yeah, that occurred to me after posting. You''re completely right. L is parallel to V.

How appropriate. You fight like a cow.
Ok now i fully understand the algorithm, just gota figure out that damn projection
Arg ive looked for like an hour and i cant find the way to project on a plane.

This topic is closed to new replies.

Advertisement