1 |
greg |
1.1 |
{ RCSid $Id$ } |
2 |
|
|
{ |
3 |
|
|
Fit Spherical Harmonic Coefficients for a Light Probe |
4 |
|
|
|
5 |
|
|
2/16/2005 G. Ward |
6 |
|
|
|
7 |
|
|
Constants: |
8 |
|
|
xres - horizontal input resolution |
9 |
|
|
yres - vertical input resolution |
10 |
|
|
map - light probe mapping (1=angular, 2=mirror) |
11 |
|
|
Usage: |
12 |
|
|
pvalue -h -H -pR -d probe.hdr \ |
13 |
|
|
| rcalc -e 'xres:512;yres:512;map:1' \ |
14 |
|
|
-f spharm.cal -f fitSH.cal \ |
15 |
|
|
| total > coef_R.dat |
16 |
|
|
Repeat for green and blue components if desired |
17 |
|
|
} |
18 |
|
|
map : 1; { just angular for now } |
19 |
|
|
|
20 |
|
|
mod(n,d) : n - floor(n/d)*d; |
21 |
|
|
sq(x) : x*x; |
22 |
|
|
|
23 |
|
|
x = mod(recno-1, xres); |
24 |
|
|
y = yres-1 - floor((recno-1)/xres); |
25 |
|
|
h = 1/xres*x - .5; |
26 |
|
|
v = 1/yres*y - .5; |
27 |
|
|
|
28 |
|
|
beta_ang = 2*PI*sqrt(h*h + v*v); |
29 |
|
|
gamma_ang = atan2(v, h); |
30 |
|
|
sine_beta_ang = sin(beta_ang); |
31 |
|
|
Dx_ang = cos(beta_ang); |
32 |
|
|
Dy_ang = cos(gamma_ang)*sine_beta_ang; |
33 |
|
|
Dz_ang = sin(gamma_ang)*sine_beta_ang; |
34 |
|
|
theta_ang = acos(Dz_ang); |
35 |
|
|
phi_ang = atan2(Dy_ang, Dx_ang); |
36 |
|
|
omega_ang = sq(4*PI/(xres+yres))*if(beta_ang-.01, sine_beta_ang/beta_ang, 1); |
37 |
|
|
|
38 |
|
|
cond = select(map, PI-1e-4-beta_ang); |
39 |
|
|
theta = select(map, theta_ang); |
40 |
|
|
phi = select(map, phi_ang); |
41 |
|
|
omega = select(map, omega_ang); |
42 |
|
|
|
43 |
|
|
{ Level 0-2 harmonics } |
44 |
|
|
$1 = $1*SphericalHarmonicB(1,theta,phi)*omega; |
45 |
|
|
$2 = $1*SphericalHarmonicB(2,theta,phi)*omega; |
46 |
|
|
$3 = $1*SphericalHarmonicB(3,theta,phi)*omega; |
47 |
|
|
$4 = $1*SphericalHarmonicB(4,theta,phi)*omega; |
48 |
|
|
$5 = $1*SphericalHarmonicB(5,theta,phi)*omega; |
49 |
|
|
$6 = $1*SphericalHarmonicB(6,theta,phi)*omega; |
50 |
|
|
$7 = $1*SphericalHarmonicB(7,theta,phi)*omega; |
51 |
|
|
$8 = $1*SphericalHarmonicB(8,theta,phi)*omega; |
52 |
|
|
$9 = $1*SphericalHarmonicB(9,theta,phi)*omega; |
53 |
|
|
{ Level 3 harmonics } |
54 |
|
|
$10 = $1*SphericalHarmonicB(10,theta,phi)*omega; |
55 |
|
|
$11 = $1*SphericalHarmonicB(11,theta,phi)*omega; |
56 |
|
|
$12 = $1*SphericalHarmonicB(12,theta,phi)*omega; |
57 |
|
|
$13 = $1*SphericalHarmonicB(13,theta,phi)*omega; |
58 |
|
|
$14 = $1*SphericalHarmonicB(14,theta,phi)*omega; |
59 |
|
|
$15 = $1*SphericalHarmonicB(15,theta,phi)*omega; |
60 |
|
|
$16 = $1*SphericalHarmonicB(16,theta,phi)*omega; |
61 |
|
|
{ Level 4 harmonics } |
62 |
|
|
$17 = $1*SphericalHarmonicB(17,theta,phi)*omega; |
63 |
|
|
$18 = $1*SphericalHarmonicB(18,theta,phi)*omega; |
64 |
|
|
$19 = $1*SphericalHarmonicB(19,theta,phi)*omega; |
65 |
|
|
$20 = $1*SphericalHarmonicB(20,theta,phi)*omega; |
66 |
|
|
$21 = $1*SphericalHarmonicB(21,theta,phi)*omega; |
67 |
|
|
$22 = $1*SphericalHarmonicB(22,theta,phi)*omega; |
68 |
|
|
$23 = $1*SphericalHarmonicB(23,theta,phi)*omega; |
69 |
|
|
$24 = $1*SphericalHarmonicB(24,theta,phi)*omega; |
70 |
|
|
$25 = $1*SphericalHarmonicB(25,theta,phi)*omega; |
71 |
|
|
{ Level 5 harmonics } |
72 |
|
|
$26 = $1*SphericalHarmonicB(26,theta,phi)*omega; |
73 |
|
|
$27 = $1*SphericalHarmonicB(27,theta,phi)*omega; |
74 |
|
|
$28 = $1*SphericalHarmonicB(28,theta,phi)*omega; |
75 |
|
|
$29 = $1*SphericalHarmonicB(29,theta,phi)*omega; |
76 |
|
|
$30 = $1*SphericalHarmonicB(30,theta,phi)*omega; |
77 |
|
|
$31 = $1*SphericalHarmonicB(31,theta,phi)*omega; |
78 |
|
|
$32 = $1*SphericalHarmonicB(32,theta,phi)*omega; |
79 |
|
|
$33 = $1*SphericalHarmonicB(33,theta,phi)*omega; |
80 |
|
|
$34 = $1*SphericalHarmonicB(34,theta,phi)*omega; |
81 |
|
|
$35 = $1*SphericalHarmonicB(35,theta,phi)*omega; |
82 |
|
|
$36 = $1*SphericalHarmonicB(36,theta,phi)*omega; |
83 |
|
|
{ Level 6 harmonics } |
84 |
|
|
$37 = $1*SphericalHarmonicB(37,theta,phi)*omega; |
85 |
|
|
$38 = $1*SphericalHarmonicB(38,theta,phi)*omega; |
86 |
|
|
$39 = $1*SphericalHarmonicB(39,theta,phi)*omega; |
87 |
|
|
$40 = $1*SphericalHarmonicB(40,theta,phi)*omega; |
88 |
|
|
$41 = $1*SphericalHarmonicB(41,theta,phi)*omega; |
89 |
|
|
$42 = $1*SphericalHarmonicB(42,theta,phi)*omega; |
90 |
|
|
$43 = $1*SphericalHarmonicB(43,theta,phi)*omega; |
91 |
|
|
$44 = $1*SphericalHarmonicB(44,theta,phi)*omega; |
92 |
|
|
$45 = $1*SphericalHarmonicB(45,theta,phi)*omega; |
93 |
|
|
$46 = $1*SphericalHarmonicB(46,theta,phi)*omega; |
94 |
|
|
$47 = $1*SphericalHarmonicB(47,theta,phi)*omega; |
95 |
|
|
$48 = $1*SphericalHarmonicB(48,theta,phi)*omega; |
96 |
|
|
$49 = $1*SphericalHarmonicB(49,theta,phi)*omega; |
97 |
|
|
{ Level 7 harmonics } |
98 |
|
|
$50 = $1*SphericalHarmonicB(50,theta,phi)*omega; |
99 |
|
|
$51 = $1*SphericalHarmonicB(51,theta,phi)*omega; |
100 |
|
|
$52 = $1*SphericalHarmonicB(52,theta,phi)*omega; |
101 |
|
|
$53 = $1*SphericalHarmonicB(53,theta,phi)*omega; |
102 |
|
|
$54 = $1*SphericalHarmonicB(54,theta,phi)*omega; |
103 |
|
|
$55 = $1*SphericalHarmonicB(55,theta,phi)*omega; |
104 |
|
|
$56 = $1*SphericalHarmonicB(56,theta,phi)*omega; |
105 |
|
|
$57 = $1*SphericalHarmonicB(57,theta,phi)*omega; |
106 |
|
|
$58 = $1*SphericalHarmonicB(58,theta,phi)*omega; |
107 |
|
|
$59 = $1*SphericalHarmonicB(59,theta,phi)*omega; |
108 |
|
|
$60 = $1*SphericalHarmonicB(60,theta,phi)*omega; |
109 |
|
|
$61 = $1*SphericalHarmonicB(61,theta,phi)*omega; |
110 |
|
|
$62 = $1*SphericalHarmonicB(62,theta,phi)*omega; |
111 |
|
|
$63 = $1*SphericalHarmonicB(63,theta,phi)*omega; |
112 |
|
|
$64 = $1*SphericalHarmonicB(64,theta,phi)*omega; |
113 |
|
|
{ Level 8 harmonics } |
114 |
|
|
$65 = $1*SphericalHarmonicB(65,theta,phi)*omega; |
115 |
|
|
$66 = $1*SphericalHarmonicB(66,theta,phi)*omega; |
116 |
|
|
$67 = $1*SphericalHarmonicB(67,theta,phi)*omega; |
117 |
|
|
$68 = $1*SphericalHarmonicB(68,theta,phi)*omega; |
118 |
|
|
$69 = $1*SphericalHarmonicB(69,theta,phi)*omega; |
119 |
|
|
$70 = $1*SphericalHarmonicB(70,theta,phi)*omega; |
120 |
|
|
$71 = $1*SphericalHarmonicB(71,theta,phi)*omega; |
121 |
|
|
$72 = $1*SphericalHarmonicB(72,theta,phi)*omega; |
122 |
|
|
$73 = $1*SphericalHarmonicB(73,theta,phi)*omega; |
123 |
|
|
$74 = $1*SphericalHarmonicB(74,theta,phi)*omega; |
124 |
|
|
$75 = $1*SphericalHarmonicB(75,theta,phi)*omega; |
125 |
|
|
$76 = $1*SphericalHarmonicB(76,theta,phi)*omega; |
126 |
|
|
$77 = $1*SphericalHarmonicB(77,theta,phi)*omega; |
127 |
|
|
$78 = $1*SphericalHarmonicB(78,theta,phi)*omega; |
128 |
|
|
$79 = $1*SphericalHarmonicB(79,theta,phi)*omega; |
129 |
|
|
$80 = $1*SphericalHarmonicB(80,theta,phi)*omega; |
130 |
|
|
$81 = $1*SphericalHarmonicB(81,theta,phi)*omega; |