1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
* Disk2Square.c |
6 |
|
* |
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 |
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; |
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 |
|
|
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 ); |
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 |
|
} |