I think you're right -- but I wouldn't be too quick to say that Steve is wrong.  On the other hand, I wound up using a completely different method so (if it will ever get into CVS) the discussion is probably overcome by events.

John F. Fay
john.fay@eglin.af.mil

-----Original Message-----
Sent: Tuesday, February 03, 2004 11:30 AM
To: plib-devel@lists.sourceforge.net
Subject: [Plib-devel] Re: Minimum distance from line to line segment in
SG

>From: Steve Baker <sjbaker1@airmail.net>
>
>Now, compute the point of closest approach of the two infinite lines (we'll
>come back to this in a moment).

Did we come back to that? Did I miss something?

>This means that you could (in principle) do the 'nearest point' calculation
>in two dimensions.  That's handy because lines ALWAYS intersect in 2D unless
>they are parallel.  You could (in principle) find the intersection of the
>projection of the infinite line into Z==0 with (Ax,Ay)-->(Bx,By)...then use
>either the x or y coordinate to get P.

Is there something wrong there?
Here is what I figured out on my own -- I could be wrong because
I don't have any geometry book.

1. If d1 and d2 are the direction vectors of the lines, then
calculate the cross product (the vector product) of d1 and d2.
That gives vector d3 which is perpendicular to both d1 and d2.

2. Rotate the world so that d3 is parallel to Z axis.

3. Intersect the rotated lines in 2D (on XY plane).
Calculate parameters (of two infinite lines) at the intersection.

4. For both lines, calculate Z coordinate at the intersection.
Min distance between infinite lines is abs(z1 - z2).

I see Steve skips the rotation, but in my opinion the 2D intersection
doesn't work without it.

Regards,
Juhana

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
plib-devel mailing list
plib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plib-devel