Line Vector Routine

Started by
3 comments, last by Andy Le Galle 22 years, 5 months ago
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
Advertisement
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Incidentally, the comp.graphics.algorithms FAQ has this and many other useful graphics algorithms.
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!
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
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement