65 |
|
The following forumulas compute Shirley-Chiu bin "scbin" based on: |
66 |
|
|
67 |
|
Dx,Dy,Dz - Incident direction (normalized, towards surface front) |
68 |
< |
Nx,Ny,Nz - Surface normal (normalized, away from surface) |
68 |
> |
rNx,rNy,rNz - Surface normal (normalized, away from surface) |
69 |
|
Ux,Uy,Uz - Up direction vector (does not need to be normalized) |
70 |
|
|
71 |
|
The SCdim variable assigns the square side dimension for bins, which are |
73 |
|
} |
74 |
|
|
75 |
|
{ Compute oriented axis values } |
76 |
< |
inc_dot = -Dx*Nx-Dy*Ny-Dz*Nz; |
77 |
< |
inc_rx = -Dx*(Uy*Nz-Uz*Ny) - Dy*(Uz*Nx-Ux*Nz) - Dz*(Ux*Ny-Uy*Nx); |
78 |
< |
inc_ry = -Dx*Ux-Dy*Uy-Dz*Uz - inc_dot*(Nx*Ux+Ny*Uy+Nz*Uz); |
76 |
> |
inc_dz = -Dx*rNx-Dy*rNy-Dz*rNz; |
77 |
> |
inc_rx = -Dx*(Uy*rNz-Uz*rNy) - Dy*(Uz*rNx-Ux*rNz) - Dz*(Ux*rNy-Uy*rNx); |
78 |
> |
inc_ry = -Dx*Ux-Dy*Uy-Dz*Uz - inc_dz*(rNx*Ux+rNy*Uy+rNz*Uz); |
79 |
|
inc_den2 = inc_rx*inc_rx + inc_ry*inc_ry; |
80 |
< |
inc_radf = if(inc_den2-1e-7, sqrt((1 - inc_dot*inc_dot)/inc_den2), 0); |
80 |
> |
inc_radf = if(inc_den2-1e-7, sqrt((1 - inc_dz*inc_dz)/inc_den2), 0); |
81 |
|
{ Pass to formulas in first section } |
82 |
|
in_disk_x = inc_rx*inc_radf; |
83 |
|
in_disk_y = inc_ry*inc_radf; |
84 |
|
{ Compute final bin (-1 if behind surface) } |
85 |
< |
scbin = if(inc_dot, |
85 |
> |
scbin = if(inc_dz, |
86 |
|
floor(out_square_x*SCdim)*SCdim + floor(out_square_y*SCdim), |
87 |
|
-1); |