hah! Someone on #gamedev on efnet brought about this theorem for testing if two coplanar line segments intersect.
line segments (a,b) and (c,d) intersect when
0 >= (ab x ac) dot (ab x ad)
and
0 >= (cd x ca) dot (cd x cb)
very elegant i must say, the poor guy had no clue how it worked though, so i had to toil away with my notebook figuring it out. Really simple actually.
If ab and cd intersect, one of two things could happen, c and d are going to be on opposite sides of a or they are goin to be on the same side of a. now if they are on opposite sides, when you take the cross product, use the right hand rule to test the direction of the cross product. If they are on different sides of the object, the cross products will have opposite signs, but if they dont intersect and they are on the same side of object a, then the cross products of (ab x ac) and (ab x ad) will have the same sign. therefore when you take the dot product, if they are on opposite sides(intersect) then the dot product is negative, if they dont intersect the dot product is positive.
now this is much faster then having to use the slope and blah blah blah.
line segments (a,b) and (c,d) intersect when
0 >= (ab x ac) dot (ab x ad)
and
0 >= (cd x ca) dot (cd x cb)
very elegant i must say, the poor guy had no clue how it worked though, so i had to toil away with my notebook figuring it out. Really simple actually.
If ab and cd intersect, one of two things could happen, c and d are going to be on opposite sides of a or they are goin to be on the same side of a. now if they are on opposite sides, when you take the cross product, use the right hand rule to test the direction of the cross product. If they are on different sides of the object, the cross products will have opposite signs, but if they dont intersect and they are on the same side of object a, then the cross products of (ab x ac) and (ab x ad) will have the same sign. therefore when you take the dot product, if they are on opposite sides(intersect) then the dot product is negative, if they dont intersect the dot product is positive.
now this is much faster then having to use the slope and blah blah blah.