4 |
|
|
5 |
|
MF - Subdivision value (usually a power of two) |
6 |
|
Dx,Dy,Dz - Incident direction (normalized, towards surface face) |
7 |
< |
Nx,Ny,Nz - Surface normal (normalized, away from surface) |
7 |
> |
rNx,rNy,rNz - Surface normal (normalized, away from surface) |
8 |
|
Ux,Uy,Uz - Up direction vector (does not need to be normalized) |
9 |
|
|
10 |
|
Modified from reinhart.cal |
13 |
|
} |
14 |
|
{ Useful factors and functions } |
15 |
|
DEGREE : PI/180; |
16 |
< |
Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))); |
17 |
< |
posangle(a) : if(-a, a + 2*PI, a); |
16 |
> |
Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))) / DEGREE; |
17 |
> |
posangle(a) : if(-a, a + 2*PI, a) / DEGREE; |
18 |
|
Atan2(y,x) : posangle(atan2(y,x)); |
19 |
|
|
20 |
|
{ Default to Tregenza sky } |
21 |
|
MF = 1; |
22 |
+ |
{ Set to -1 for left-handed coordinate system } |
23 |
+ |
RHS = 1; |
24 |
|
{ Default axis orientation (+Y == north) } |
25 |
< |
Nx = 0; Ny = 0; Nz = 1; |
25 |
> |
rNx = 0; rNy = 0; rNz = -1; |
26 |
|
Ux = 0; Uy = 1; Uz = 0; |
27 |
|
{ Compute oriented axis angles } |
28 |
< |
inc_dz = -Dx*Nx-Dy*Ny-Dz*Nz; |
29 |
< |
inc_rx = -Dx*(Uy*Nz-Uz*Ny) - Dy*(Uz*Nx-Ux*Nz) - Dz*(Ux*Ny-Uy*Nx); |
30 |
< |
inc_ry = -Dx*Ux-Dy*Uy-Dz*Uz - inc_dz*(Nx*Ux+Ny*Uy+Nz*Uz); |
28 |
> |
inc_dz = -Dx*rNx-Dy*rNy-Dz*rNz; |
29 |
> |
inc_rx = -RHS*(Dx*(Uy*rNz-Uz*rNy) + Dy*(Uz*rNx-Ux*rNz) + Dz*(Ux*rNy-Uy*rNx)); |
30 |
> |
inc_ry = Dx*Ux+Dy*Uy+Dz*Uz + inc_dz*(rNx*Ux+rNy*Uy+rNz*Uz); |
31 |
|
|
32 |
< |
r_alt = Asin(inc_dz)/DEGREE; |
33 |
< |
r_azi = Atan2(inc_rx,inc_ry)/DEGREE; |
32 |
> |
r_alt = Asin(inc_dz); |
33 |
> |
r_azi = Atan2(inc_rx,inc_ry); |
34 |
|
|
35 |
|
alpha = 90/(MF*7 + .5); { Separation between rows in degrees } |
36 |
|
{ Number of patches per row } |