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

Comparing ray/src/common/disk2square.c (file contents):
Revision 3.1 by greg, Fri Feb 18 00:40:25 2011 UTC vs.
Revision 3.6 by greg, Wed Dec 15 01:39:52 2021 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char RCSid[] = "$Id$";
3 + #endif
4   /*
5   *  Disk2Square.c
6   *  
# Line 8 | Line 11
11   * Modified interface slightly (G. Ward)
12   */
13  
14 + #define _USE_MATH_DEFINES
15   #include <math.h>
16 + #include "fvect.h"
17  
18   /*
19   This transforms points on [0,1]^2 to points on unit disk centered at
# Line 36 | Line 41 | change log:
41  
42   /* Map a [0,1]^2 square to a unit radius disk */
43   void
44 < SDsquare2disk(double ds[2], double seedx, double seedy)
44 > square2disk(RREAL ds[2], double seedx, double seedy)
45   {
46  
47     double phi, r;
# Line 66 | Line 71 | SDsquare2disk(double ds[2], double seedx, double seedy
71                  phi = 0.;
72         }
73     }
74 <
74 >   r *= 0.9999999999999;        /* prophylactic against MS sin()/cos() impl. */
75     ds[0] = r * cos(phi);
76     ds[1] = r * sin(phi);
77  
# Line 74 | Line 79 | SDsquare2disk(double ds[2], double seedx, double seedy
79  
80   /* Map point on unit disk to a unit square in [0,1]^2 range */
81   void
82 < SDdisk2square(double sq[2], double diskx, double disky)
82 > disk2square(RREAL sq[2], double diskx, double disky)
83   {
84      double r = sqrt( diskx*diskx + disky*disky );
85      double phi = atan2( disky, diskx );
# Line 98 | Line 103 | SDdisk2square(double sq[2], double diskx, double disky
103          a = -(phi - 3*M_PI/2) * b / (M_PI/4);
104      }
105  
106 <    sq[0] = (a + 1) * 0.5;
107 <    sq[1] = (b + 1) * 0.5;
106 >    sq[0] = a*(0.5/0.9999999999999) + 0.5;
107 >    sq[1] = b*(0.5/0.9999999999999) + 0.5;
108   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines