Archived

This topic is now archived and is closed to further replies.

Andy Le Galle

Line Vector Routine

Recommended Posts

Hi all, I have a little problem with the maths for my engine ( well, just me being thick really ). I cant seem to write an algorithm to fine the intersection of two lines in 3d (if they intersect). This involves solving simultainiously two lines in the form r=u+tv; when u and v are vectors. Just cant seem to figure out the in code alternative to the brain work. Can anyone help?? Thanks, Andy

Share this post


Link to post
Share on other sites
Small plug : I wrote a chapter on this exact question for the book Game Programming Gems 2.

The content I wrote is now copyrighted by the publisher and so I can''t provide it here. I will give a hint, though. Set the two line equations equal to each other, say u1+t1*v1 = u2+t2*v2. You will be solving for the parameter values t1 and t2. Your line equations are linear equations, and so you''re solving a system of linear equations. The thing is, you have 3 equations, one for each coordinate x, y, z, and only two unknowns. Its an overdetermined system in general, so you have to figure out/remember how to solve an overdetermined system. And you have to deal with the case where the lines are parallel or degenerate.

You may receive responses from other folks here, and they may be sufficient. Heck, my clue may be sufficient. But the book chapter has a comprehensive solution and working source code. And if you need to deal with finite-length line segments (rather than infinite lines), the book chapter treats that case as well. That''s another plug, by the way!

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by grhodes_at_work
Small plug : I wrote a chapter on this exact question for the book Game Programming Gems 2...The content I wrote is now copyrighted by the publisher and so I can''t provide it here.

Wow, you can''t reproduce your own work?
Damn, publishers are bitches!

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Wow, you can't reproduce your own work?
Damn, publishers are bitches!



I can't reproduce without permission, since I assigned copyright to them. I suppose I do have a hidden agenda to try and increase the sales of the book....

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Edited by - grhodes_at_work on November 14, 2001 1:39:59 PM

Share this post


Link to post
Share on other sites