POV-Ray : Newsgroups : povray.off-topic : Haskell vs Java: Building a ray tracer : Re: Haskell vs Java: Building a ray tracer Server Time
29 Jul 2024 08:21:21 EDT (-0400)
  Re: Haskell vs Java: Building a ray tracer  
From: Orchid Win7 v1
Date: 29 Jun 2012 17:58:54
Message: <4fee251e$1@news.povray.org>
>>> As Clipka pointed out, you need to calculate all intersections anyway to
>>> find the nearest one.
>>
>> And as I pointed out, this is not the case for many objects. E.g., a
>> sphere has two points of intersection. These are the solutions to a
>> quadratic equation. And we all know that the way to solve that is
>>
>> x = -b +/- Sqrt(b^2 - 4ac) / 2a
>>
>> To find the "nearest" intersection, you merely pick the "-" rather than
>> the "+". Done.
>
> Assuming your sphere is to the "right" of your ray starting point.

No assumption.

The result of this equation is the distance along the ray that you need 
to travel to get to the intersection. Therefore, the lowest solution is 
guaranteed to be the one you want. (Unless the camera is /inside/ the 
sphere, which won't work for several other reasons besides this one.)


Post a reply to this message

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