POV-Ray : Newsgroups : povray.advanced-users : 3D mathematics question : Re: 3D mathematics question Server Time
28 Jul 2024 16:24:33 EDT (-0400)
  Re: 3D mathematics question  
From: Andrew the Orchid
Date: 8 Nov 2004 17:06:20
Message: <418feddc@news.povray.org>
> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.