POV-Ray : Newsgroups : povray.advanced-users : 3D mathematics question : Re: 3D mathematics question Server Time
28 Jul 2024 16:25:37 EDT (-0400)
  Re: 3D mathematics question  
From: Tor Olav Kristensen
Date: 8 Nov 2004 17:38:29
Message: <418ff565$1@news.povray.org>
Andrew the Orchid wrote:
>> 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!

Yes that looks elegant.

When I sit down and figure out such things myself,
I continue until the solution is as simple as I
can manage to make it.

If it then does not look elegant, then it's probably
not the best solution.

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

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