|
|
> Inverse trigonometric operations are slow.
>
> Try this search:
>
> http://www.google.com/search?q=efficient+line+triangle+intersection
Was about to try something even more complex and longwinded. But the
very first link gives me this:
Plane thru A, B, C is given by
P(u, v) = A + u*AB + v*AC
Line thru J, K is given by
L(t) = J + t*JK
Intersection of P and L is I=L(t) where
t = N . (A - P) / N . (Q - P)
u,v coordinate of I is
u = AI . (N x AC) / AB . (N x AC)
v = AI . (N x AB) / AC . (N x AB)
(N = normal of the plane).
Finally, the point lies within the triangle iff
u >= 0
v >= 0
u+v <= 1
Add to that a check in case the line and triangle are perpendicular -
and anoter check because I want my line to be finite length (check that
0<=t<=1) and we're done! Ha!
Andrew.
Post a reply to this message
|
|