View Single Post
  #2  
Old January 18th, 2008, 07:56 AM
CaptainBlack's Avatar
CaptainBlack CaptainBlack is offline
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,375
Country:
Thanks: 667
Thanked 3,618 Times in 2,915 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

Quote:
Originally Posted by jacksoncapper View Post
I have been trying so long to do this simple thing. I have two 3D line segments, each represented by two points. I need to know if and where these two lines intersect, but I need a method that I can implement programmatically in an algorithm. Please any help would be greatly appreciated.
Let the points be \bf{x} and \bf{y} and \bf{u} and \bf{v} . Then the line segments are:

\bold{l_1}=\bold{x}+ \lambda (\bold{y}-\bold{x}),\ \lambda \in [0,1]
\bold{l_2}=\bold{u}+ \mu (\bold{v}-\bold{u}),\ \mu \in [0,1]


The lines intersect if there are \lambda,\ \mu \in [0,1] such that:

\bold{x}+ \lambda (\bold{y}-\bold{x})=\bold{u}+ \mu (\bold{v}-\bold{u})

Now write these out in terms of the components and you have three
simultaneous linear equations for \lambda and \mu . If there is a solution
with \lambda and \mu \in [0,1] then the line segments intersect.

RonL
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno

Last edited by CaptainBlack; January 19th, 2008 at 08:18 AM.
Reply With Quote