ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rambpos.cal
Revision: 2.7
Committed: Wed Sep 3 14:05:55 2014 UTC (8 years, 1 month ago) by greg
Branch: MAIN
CVS Tags: rad5R0, rad5R2, rad4R2P2, rad4R2P1, rad5R1, rad5R3, HEAD
Changes since 2.6: +5 -2 lines
Log Message:
Added corral flag highlighting

File Contents

# Content
1 { RCSid $Id: rambpos.cal,v 2.6 2014/05/15 17:30:53 greg Exp $ }
2 {
3 Compute ambient position factors for genambpos.pl
4 }
5 and(a,b) : if(a,b,a);
6 { level selector }
7 lvl = $10;
8 wt = $11;
9 r0 = SF*$12; r1 = SF*$13;
10 eps = r0*.015;
11 acond = and( r0-5e-5, and( wt-MW, if(LV+.5, and(lvl-LV+.5,LV+.5-lvl), 6.5-lvl) ) );
12 nx = $4; ny = $5; nz = $6;
13 ux = $7; uy = $8; uz = $9;
14 vx = ny*uz - nz*uy;
15 vy = nz*ux - nx*uz;
16 vz = nx*uy - ny*ux;
17 px = $1 + nx*eps;
18 py = $2 + ny*eps;
19 pz = $3 + nz*eps;
20 avr = .5/PI*$14; avg = .5/PI*$15; avb = .5/PI*$16;
21 { magnified position gradient }
22 pgx = ($17*ux + $18*vx)/SF;
23 pgy = ($17*uy + $18*vy)/SF;
24 pgz = ($17*uz + $18*vz)/SF;
25 pg = sqrt(pgx*pgx + pgy*pgy + pgz*pgz);
26 pcond = and( acond, pg - .0001 );
27 { direction gradient }
28 dgx = $19*ux + $20*vx;
29 dgy = $19*uy + $20*vy;
30 dgz = $19*uz + $20*vz;
31 dg = sqrt(dgx*dgx + dgy*dgy + dgz*dgz);
32 { corral flags pattern }
33 cflags = $21;
34 { ambient position color }
35 val = avr + avg + avb;
36 agr = select(lvl+1, val, 0, 0, val, 0, val, val);
37 agg = select(lvl+1, 0, val, 0, val, val, 0, val/2);
38 agb = select(lvl+1, 0, 0, val, 0, val, val, val/2);
39 psiz = r0/10;
40 dcond = and( acond, dg - .0001 );
41 { base polygon vertices }
42 px1 = px + r0*ux + r1*vx;
43 py1 = py + r0*uy + r1*vy;
44 pz1 = pz + r0*uz + r1*vz;
45 px2 = px - r0*ux + r1*vx;
46 py2 = py - r0*uy + r1*vy;
47 pz2 = pz - r0*uz + r1*vz;
48 px3 = px - r0*ux - r1*vx;
49 py3 = py - r0*uy - r1*vy;
50 pz3 = pz - r0*uz - r1*vz;
51 px4 = px + r0*ux - r1*vx;
52 py4 = py + r0*uy - r1*vy;
53 pz4 = pz + r0*uz - r1*vz;
54 alen = psiz*3; { arrow length & coordinates }
55 cx0 = px + psiz*psiz/alen*pgx/pg;
56 cy0 = py + psiz*psiz/alen*pgy/pg;
57 cz0 = pz + psiz*psiz/alen*pgz/pg;
58 cr0 = psiz*sqrt(1 - psiz*psiz/(alen*alen));
59 cx1 = px + alen*pgx/pg;
60 cy1 = py + alen*pgy/pg;
61 cz1 = pz + alen*pgz/pg;