ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/renders/diskcoords.cal
Revision: 1.1
Committed: Fri Nov 30 17:49:59 2018 UTC (6 years, 5 months ago) by greg
Branch: MAIN
Log Message:
Initial version before changing to rayinit.cal local coordinate calculations

File Contents

# Content
1 { RCSid $Id$ }
2 {
3 Shirley-Chiu coordinate calculation for BRDF data types (plasdata, metdata)
4
5 Assumes material in X-Y plane with Y axis "up" and surface normal is Z-axis
6 }
7 Up(i) = arg(AC-3+i); { up vector does not need to be normalized }
8 Vux = cross(1,Up,N);
9 Vuy = cross(2,Up,N);
10 Vuz = cross(3,Up,N);
11 vnorm = 1/sqrt(Vux*Vux + Vuy*Vuy + Vuz*Vuz);
12 Vnx = Vux*vnorm;
13 Vny = Vuy*vnorm;
14 Vnz = Vuz*vnorm;
15 Vn(i) = select(i, Vnx, Vny, Vnz);
16 Unx = cross(1,N,Vn);
17 Uny = cross(2,N,Vn);
18 Unz = cross(3,N,Vn);
19 { Transform vectors, normalized (dx,dy,dz) away from surf }
20 surf_dx(dx,dy,dz) = dx*Unx + dy*Uny + dz*Unz;
21 surf_dy(dx,dy,dz) = dx*Vnx + dy*Vny + dz*Vnz;
22 surf_dz(dx,dy,dz) = dx*Nx + dy*Ny + dz*Nz;
23
24 inc_dx = surf_dx(-Dx,-Dy,-Dz);
25 inc_dy = surf_dy(-Dx,-Dy,-Dz);
26 inc_dz = Rdot;
27 { Compute square position from disk coordinates }
28 norm_radians(p) : if(-p - PI/4, p + 2*PI, p);
29 idr(idx,idy) = sqrt(idx*idx + idy*idy);
30 idp(idx,idy) = norm_radians(atan2(idy, idx));
31
32 idrgn(idp) = floor((idp + PI/4)/(PI/2)) + 1;
33
34 square_a(idr,idp) = select(idrgn(idp),
35 idr,
36 (PI/2 - idp)*idr/(PI/4),
37 -idr,
38 (idp - 3*PI/2)*idr/(PI/4));
39
40 square_b(idr,idp) = select(idrgn(idp),
41 idp*idr/(PI/4),
42 idr,
43 (PI - idp)*idr/(PI/4),
44 -idr);
45
46 square_x(idx,idy) = (square_a(idr(idx,idy),idp(idx,idy)) + 1)/2;
47 square_y(idx,idy) = (square_b(idr(idx,idy),idp(idx,idy)) + 1)/2;
48
49 inc_sqx = square_x(-inc_dx,-inc_dy); { Negative because of Klems reversal }
50 inc_sqy = square_y(-inc_dx,-inc_dy);
51
52 sqx_in(sx,sy,sz) = inc_sqx; { Only a function of incident ray direction }
53 sqy_in(sx,sy,sz) = inc_sqy;
54
55 sqx_out(sx,sy,sz) = square_x(surf_dx(sx,sy,sz),surf_dy(sx,sy,sz));
56 sqy_out(sx,sy,sz) = square_y(surf_dx(sx,sy,sz),surf_dy(sx,sy,sz));