[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [ATM] Raytracing Function



At 2006-09-26 20:12 -0500, Donald Good wrote:

>float OffsetRt(float a, float x ) {
>    if (a<0) Return (sqrt( a*a + x ) - a);
>    else Return (x/(sqrt( a*a + x) + a));

At 2006-09-27 18:14 -0400, Richard F.L.R. Snashall wrote:

>Yes, or, equivalently, to find the smallest magnitude (I think)
>root y of y^2 + 2*a*y + x = 0:
>
>    double SmRt( double a, double x )
>      {
>      if( a < 0.0 )
>        {
>        return x / ( sqrt( a * a - x ) - a );
>        }
>      else if( a > 0.0 )
>        {
>        return - x / ( sqrt( a * a - x ) + a );
>        }
>      else
>        {
>        return sqrt( - x );
>        }
>      }
>
>the other root being - ( y + 2 * a ).

Let's get this based on reality.  The height y of the conic surface with 
radius of curvature R, and conic constant b at zone radius x is the 
solution of the quadratic equation

         py² - 2Ry + x² = 0, with p = b + 1.

If we assume R > 0, then the solution is y = x²/(R + sqrt( R² - 
px²)).  Unfortunately in ray tracing, sign conventions may force R to be 
negative - in that case, I'd use -R in the formula, then dredge up a mental 
image to decide whether y is plus or minus.

It's cute that you run into this even using wave optics - there's a lot of 
calculating OPDs from source to surface point to image center, and it has 
to be good to a fraction of a wave length.

         -- Jim Burrows
         -- mailto://burrjaw@earthlink.net
         -- http://home.earthlink.net/~burrjaw
         -- Seattle N47.4723 W122.3662 (WGS84)  

_______________________________________________
ATM mailing list http://www.atmlist.net/