#### Archived

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

# Line Vector Routine

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

## 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 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 on other sites
Incidentally, the comp.graphics.algorithms FAQ has this and many other useful graphics algorithms.

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

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 27
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631407
• Total Posts
2999914
×