ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/tcos.c
(Generate patch)

Comparing ray/src/common/tcos.c (file contents):
Revision 3.6 by greg, Thu Jan 17 22:48:21 2013 UTC vs.
Revision 3.7 by greg, Thu Feb 7 20:19:52 2013 UTC

# Line 50 | Line 50 | tcos(double x)                         /* approximate cosine */
50          }
51          return(0.);             /* should never be reached */
52   }
53 +
54 +
55 + /* Fast arctangent approximation due to Rajan et al. 2006 */
56 + double
57 + aatan2(double y, double x)
58 + {
59 +        double  ratio, aratio, val;
60 +
61 +        if (x == 0)
62 +                return (y > 0) ? PI/2. : 3./2.*PI;
63 +
64 +        aratio = (ratio = y/x) >= 0 ? ratio : -ratio;
65 +
66 +        if (aratio > 1.01)
67 +                return PI/2. - aatan2(x, y);
68 +
69 +        val = PI/4.*ratio - ratio*(aratio - 1.)*(0.2447 + 0.0663*aratio);
70 +
71 +        return val + PI*(x < 0);
72 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines