POV-Ray : Newsgroups : povray.off-topic : Bounding circle intersection : Re: Bounding circle intersection Server Time
5 Sep 2024 01:21:08 EDT (-0400)
  Re: Bounding circle intersection  
From: Invisible
Date: 11 Dec 2009 05:54:20
Message: <4b2224dc$1@news.povray.org>
>> Wouldn't it be faster to just directly check the line against the 
>> triangle?
> 
> Honestly, I don't know. I'm not sure my code for the triangle-line check is 
> very good. =)
> 
> As far as I can tell, to check for an intersection between a triangle and a 
> line segment, you need to check that one of the triangle's vertices is on an 
> opposite side of the line from the other two, and then check that both of 
> the line segment's endpoints are on opposite sides of at least one of the 
> triangle's edges, or that both of them are inside the triangle.
> 
> I did most of these checks with cross products, and then found I had some 
> precision problems in some cases, and the code got more complicated when I 
> tried to avoid them. Since intersections are rare, I figured a bounding 
> check would be the easiest way to improve performance.

Er... yeah, that's not terribly good. ;-)

Do a quick google for "ray triangle intersection". There are several 
methods for doing this kind of thing, some of them highly optimised.


Post a reply to this message

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