--- ray/src/util/reinhartb.cal 2014/07/22 02:12:48 2.1 +++ ray/src/util/reinhartb.cal 2014/08/26 18:56:19 2.5 @@ -1,10 +1,10 @@ -{ RCSid $Id: reinhartb.cal,v 2.1 2014/07/22 02:12:48 greg Exp $ } +{ RCSid $Id: reinhartb.cal,v 2.5 2014/08/26 18:56:19 greg Exp $ } { Compute Reinhart high-density sky patch bin (rbin) MF - Subdivision value (usually a power of two) Dx,Dy,Dz - Incident direction (normalized, towards surface face) - Nx,Ny,Nz - Surface normal (normalized, away from surface) + rNx,rNy,rNz - Surface normal (normalized, away from surface) Ux,Uy,Uz - Up direction vector (does not need to be normalized) Modified from reinhart.cal @@ -13,22 +13,22 @@ } { Useful factors and functions } DEGREE : PI/180; -Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))); -posangle(a) : if(-a, a + 2*PI, a); +Asin(x) : if(x-1, PI/2, if(-1-x, -PI/2, asin(x))) / DEGREE; +posangle(a) : if(-a, a + 2*PI, a) / DEGREE; Atan2(y,x) : posangle(atan2(y,x)); { Default to Tregenza sky } MF = 1; { Default axis orientation (+Y == north) } -Nx = 0; Ny = 0; Nz = 1; +rNx = 0; rNy = 0; rNz = -1; Ux = 0; Uy = 1; Uz = 0; { Compute oriented axis angles } -inc_dz = -Dx*Nx-Dy*Ny-Dz*Nz; -inc_rx = -Dx*(Uy*Nz-Uz*Ny) - Dy*(Uz*Nx-Ux*Nz) - Dz*(Ux*Ny-Uy*Nx); -inc_ry = -Dx*Ux-Dy*Uy-Dz*Uz - inc_dz*(Nx*Ux+Ny*Uy+Nz*Uz); +inc_dz = -Dx*rNx-Dy*rNy-Dz*rNz; +inc_rx = -Dx*(Uy*rNz-Uz*rNy) - Dy*(Uz*rNx-Ux*rNz) - Dz*(Ux*rNy-Uy*rNx); +inc_ry = Dx*Ux+Dy*Uy+Dz*Uz + inc_dz*(rNx*Ux+rNy*Uy+rNz*Uz); -r_alt = Asin(inc_dz)/DEGREE; -r_azi = Atan2(inc_rx,inc_ry)/DEGREE; +r_alt = Asin(inc_dz); +r_azi = Atan2(inc_rx,inc_ry); alpha = 90/(MF*7 + .5); { Separation between rows in degrees } { Number of patches per row }