ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/util/klems_half.cal
(Generate patch)

Comparing ray/src/util/klems_half.cal (file contents):
Revision 1.5 by greg, Thu Jul 14 02:52:02 2022 UTC vs.
Revision 1.6 by greg, Fri Nov 14 23:51:42 2025 UTC

# Line 7 | Line 7
7  
8          7/18/2014       G. Ward
9   }
10 < DEGREE : PI/180;
10 > DEGREE` : PI/180;
11 > mod`(n,d) : n - floor(n/d)*d;
12   Acos(x) : if(x-1, 0, if(-1-x, PI, acos(x))) / DEGREE;
12 posangle(a) : if(-a, a + 2*PI, a) / DEGREE;
13 Atan2(y,x) : posangle(atan2(y,x));
13  
14   khpola(r) : select(r, 6.5, 19.5, 32.5, 45.5, 58.5, 71.5, 90);
15 + KHAPS : khpola(3) - khpola(2);
16   khnaz(r) : select(r, 1, 8, 12, 16, 20, 12, 8);
17   khaccum(r) : if(r-.5, khnaz(r) + khaccum(r-1), 0);
18   khfindrow(r, pol) : if(r-khpola(0)+.5, r,
19                  if(pol-khpola(r), khfindrow(r+1, pol), r) );
20  
21 < khazn(azi,inc) : if((360-.5*inc)-azi, floor((azi+.5*inc)/inc), 0);
21 > RHS = 1;        { Set to -1 for left-handed system }
22 > JTR = 0;        { Sharp bin boundaries by default }
23 >                                { Uniform perturbation function }
24 > kjtr(n) = if(JTR, JTR*(.5 - rand(n*(9.54*Dx - 5.11*Dy + 1.37*Dz - 6.71))), 0);
25  
26 < khbin2(pol,azi) = if(pol-90, -1,
26 > kazn(azi,inc) = floor( mod(azi + inc*(.5+kjtr(2)), 360) / inc );
27 >
28 > khbin2(pol,azi) =
29          select(khfindrow(1, pol),
30 <                khazn(azi,360/khnaz(1)),
31 <                khaccum(1) + khazn(azi,360/khnaz(2)),
32 <                khaccum(2) + khazn(azi,360/khnaz(3)),
33 <                khaccum(3) + khazn(azi,360/khnaz(4)),
34 <                khaccum(4) + khazn(azi,360/khnaz(5)),
35 <                khaccum(5) + khazn(azi,360/khnaz(6)),
36 <                khaccum(6) + khazn(azi,360/khnaz(7))
37 <        ) );
30 >                kazn(azi,360/khnaz(1)),
31 >                khaccum(1) + kazn(azi,360/khnaz(2)),
32 >                khaccum(2) + kazn(azi,360/khnaz(3)),
33 >                khaccum(3) + kazn(azi,360/khnaz(4)),
34 >                khaccum(4) + kazn(azi,360/khnaz(5)),
35 >                khaccum(5) + kazn(azi,360/khnaz(6)),
36 >                khaccum(6) + kazn(azi,360/khnaz(7))
37 >        );
38  
39 < RHS = 1;        { set to -1 for left-handed system }
39 > khbin1(zv,yv,xv) = if(zv, khbin2(min(max(0, Acos(zv) + KHAPS*kjtr(1)), 90),
40 >                                atan2(yv,xv)/DEGREE),
41 >                        -1);
42  
43 < khbin(Nx,Ny,Nz,Ux,Uy,Uz) = khbin2(Acos(-Dx*Nx-Dy*Ny-Dz*Nz),
44 <        Atan2(-Dx*Ux-Dy*Uy-Dz*Uz + (Nx*Dx+Ny*Dy+Nz*Dz)*(Nx*Ux+Ny*Uy+Nz*Uz),
45 <                -RHS*(Dx*(Uy*Nz-Uz*Ny) + Dy*(Uz*Nx-Ux*Nz) + Dz*(Ux*Ny-Uy*Nx))));
43 > khbin(Nx,Ny,Nz,Ux,Uy,Uz) = khbin1(-Dx*Nx-Dy*Ny-Dz*Nz,
44 >        -Dx*Ux-Dy*Uy-Dz*Uz + (Nx*Dx+Ny*Dy+Nz*Dz)*(Nx*Ux+Ny*Uy+Nz*Uz),
45 >                -RHS*(Dx*(Uy*Nz-Uz*Ny) + Dy*(Uz*Nx-Ux*Nz) + Dz*(Ux*Ny-Uy*Nx)));
46                                  
47   Nkhbins : khaccum(khnaz(0));    { Number of bins for one elevation }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)