|
![](/i/fill.gif) |
>>> 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
|
![](/i/fill.gif) |