POV-Ray : Newsgroups : povray.off-topic : Ray tracers and transformations : Re: Ray tracers Server Time
10 Oct 2024 17:19:59 EDT (-0400)
  Re: Ray tracers  
From: Slime
Date: 14 Mar 2008 02:28:22
Message: <47da2916$1@news.povray.org>
> double Mass::intersect(Vector origin, Vector direction) const
> {
>    Vector relPosition = position - origin;
>    double radius2 = radius * radius;
>    double nearestPointDistance = relPosition*direction;
>
>    double halfChord2 = radius2 - relPosition*relPosition +
> nearestPointDistance*nearestPointDistance;
>
>    if(halfChord2 > 0.0)
>    {
>        double nearPoint = nearestPointDistance - sqrt(halfChord2);
>        double farPoint = nearestPointDistance + sqrt(halfChord2);
>        if(nearPoint > EPSILON)
>            return nearPoint;
>        else
>            return farPoint;
>    }
>    else
>        return -1.0;
> }

Is this what POV-Ray actually uses for the intersection of a ray and a 
sphere? I just spent half an hour working out both the geometrical 
interpretation of this and its equivalence to the result of the quadratic 
equation with the coefficients that Andrew posted, and I'm really impressed 
at how simple it is. And annoyed at the fact that I never could have come up 
with it myself =)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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