ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ambpos.cal
Revision: 2.4
Committed: Wed Sep 3 14:05:55 2014 UTC (9 years, 7 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2P1, rad5R3, HEAD
Changes since 2.3: +12 -1 lines
Log Message:
Added corral flag highlighting

File Contents

# Content
1 { RCSid $Id: ambpos.cal,v 2.3 2014/05/01 03:00:59 greg Exp $ }
2 {
3 Compute patterns for ambient position markers
4 }
5 odd(n) : .5*n - floor(.5*n) - .25;
6 posangle(a) : if(-a, a + 2*PI, a) / DEGREE;
7 { Relative hit point }
8 rpx = Px - arg(1);
9 rpy = Py - arg(2);
10 rpz = Pz - arg(3);
11
12 { Calculation of directional gradient pattern }
13 ndx = arg(4); ndy = arg(5); ndz = arg(6);
14 dgx = arg(7); dgy = arg(8); dgz = arg(9);
15 rdx = ndy*rpz - ndz*rpy;
16 rdy = ndz*rpx - ndx*rpz;
17 rdz = ndx*rpy - ndy*rpx;
18 dgrad = (rdx*dgx + rdy*dgy + rdz*dgz)/sqrt(rpx*rpx + rpy*rpy + rpz*rpz);
19 dirfunc = bound(0, 1 + dgrad, 2);
20
21 { Calculation of positional gradient pattern }
22 pgx = arg(4); pgy = arg(5); pgz = arg(6);
23 posfunc = bound(0, 1 + (pgx*rpx + pgy*rpy + pgz*rpz), 2);
24 { corral flags and associated pattern }
25 ux = arg(4); uy = arg(5); uz = arg(6);
26 cflags = arg(7);
27 vx = Ny*uz - Nz*uy;
28 vy = Nz*ux - Nx*uz;
29 vz = Nx*uy - Ny*ux;
30 cflg(i) = if(odd(floor( cflags / 2^i )), 1, -1);
31 corralled = cflg(floor(32/360*posangle(
32 atan2(rpx*vx+rpy*vy+rpz*vz, rpx*ux+rpy*uy+rpz*uz) )));
33
34 { Calculation of ellipse stencil for base }
35 usx = arg(4); usy = arg(5); usz = arg(6);
36 vsx = arg(7); vsy = arg(8); vsz = arg(9);
37 ellipstencil = if(1 - sq(usx*rpx + usy*rpy + usz*rpz) - sq(vsx*rpx + vsy*rpy + vsz*rpz),
38 1, 0);