I have two 3D lines which lie on the same plane. line1
is defined by a point (x1, y1, z1
) and its direction vector (a1, b1, c1
) while line2
is defined by a point (x2, y2, z2
) and its direction vector (a2, b2, c2
). Then the parametric equations for both lines are
x = x1 + a1*t; x = x2 + a2*s;
y = y1 + b1*t; y = y2 + b2*s;
z = z1 + c1*t; z = z2 + c2*s;
If both direction vectors are nonzeros, we can find out the location of intersection node easily by equating the right-hand-side of the equations above and solving t
and s
from either two of the three. However, it's possible that a1 b1 c1 a2 b2 c2
are not all nonzero so that I can't solve those equations in the same way. My current thought is to deal with this issue case by case, like
case1: a1 = 0, others are nonzero
case2: a2 = 0, others are nonzero
case3: b1 = 0, others are nonzero
...
However, there are so many cases in total and the implementation would become messy. Is there any good ways to tackle this problem? Any reference? Thanks a lot!