84 |
|
dim[3] = 1; |
85 |
|
r1 = (dim[1]+urand(urind(ilhash(dim,4),i)))/nalt; |
86 |
|
dim[3] = 2; |
87 |
< |
r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nalt; |
87 |
> |
r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nazi; |
88 |
|
flatdir(dn, r1, r2); |
89 |
|
for (j = 0; j < 3; j++) |
90 |
< |
dir[j] = dn[0]*u[j] + dn[1]*v[j] - dn[2]*fa->norm[j]; |
90 |
> |
dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j]; |
91 |
|
/* random location */ |
92 |
|
do { |
93 |
|
dim[3] = 3; |
133 |
|
int dim[4]; |
134 |
|
int n, nalt, nazi; |
135 |
|
float *distarr; |
136 |
< |
double r1, r2; |
136 |
> |
double r1, r2, r3; |
137 |
|
FVECT org, dir; |
138 |
|
FVECT u, v; |
139 |
|
register int i, j; |
151 |
|
dim[0] = random(); |
152 |
|
/* sample sphere */ |
153 |
|
for (dim[1] = 0; dim[1] < nalt; dim[1]++) |
154 |
< |
for (dim[2] = 0; dim[2] < nazi; dim[2]++) |
154 |
> |
for (dim[2] = 0; dim[2] < nazi; dim[2]++) { |
155 |
> |
if (il->nsamps > 2 && nazi > 20) { |
156 |
> |
rounddir(dir, (dim[1]+.5)/nalt, (dim[2]+.5)/nazi); |
157 |
> |
mkaxes(u, v, dir); |
158 |
> |
} |
159 |
|
for (i = 0; i < il->nsamps; i++) { |
160 |
|
/* random direction */ |
161 |
|
dim[3] = 1; |
162 |
|
r1 = (dim[1]+urand(urind(ilhash(dim,4),i)))/nalt; |
163 |
|
dim[3] = 2; |
164 |
< |
r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nalt; |
164 |
> |
r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nazi; |
165 |
|
rounddir(dir, r1, r2); |
166 |
|
/* random location */ |
167 |
< |
mkaxes(u, v, dir); /* yuck! */ |
167 |
> |
if (il->nsamps <= 2 || nazi <= 20) |
168 |
> |
mkaxes(u, v, dir); /* yuck! */ |
169 |
|
dim[3] = 3; |
170 |
< |
r1 = sqrt(urand(urind(ilhash(dim,4),i))); |
170 |
> |
r3 = sqrt(urand(urind(ilhash(dim,4),i))); |
171 |
|
dim[3] = 4; |
172 |
|
r2 = 2.*PI*urand(urind(ilhash(dim,4),i)); |
173 |
< |
for (j = 0; j < 3; j++) |
174 |
< |
org[j] = ob->oargs.farg[j] + ob->oargs.farg[3] * |
175 |
< |
( r1*cos(r2)*u[j] + r1*sin(r2)*v[j] |
176 |
< |
- sqrt(1.01-r1*r1)*dir[j] ); |
177 |
< |
|
173 |
> |
r1 = r3*ob->oargs.farg[3]*cos(r2); |
174 |
> |
r2 = r3*ob->oargs.farg[3]*sin(r2); |
175 |
> |
r3 = ob->oargs.farg[3]*sqrt(1.01-r3*r3); |
176 |
> |
for (j = 0; j < 3; j++) { |
177 |
> |
org[j] = ob->oargs.farg[j] + r1*u[j] + r2*v[j] + |
178 |
> |
r3*dir[j]; |
179 |
> |
dir[j] = -dir[j]; |
180 |
> |
} |
181 |
|
/* send sample */ |
182 |
|
raysamp(distarr+dim[1]*nazi+dim[2], org, dir, rt); |
183 |
|
} |
184 |
+ |
} |
185 |
|
rayflush(rt); |
186 |
|
/* write out the sphere w/ distribution */ |
187 |
|
roundout(il, distarr, nalt, nazi); |
200 |
|
int dim[4]; |
201 |
|
int n, nalt, nazi; |
202 |
|
float *distarr; |
203 |
< |
double r1, r2; |
203 |
> |
double r1, r2, r3; |
204 |
|
FVECT dn, org, dir; |
205 |
|
FVECT u, v; |
206 |
|
register CONE *co; |
228 |
|
r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nalt; |
229 |
|
flatdir(dn, r1, r2); |
230 |
|
for (j = 0; j < 3; j++) |
231 |
< |
dir[j] = dn[0]*u[j] + dn[1]*v[j] - dn[2]*co->ad[j]; |
231 |
> |
dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j]; |
232 |
|
/* random location */ |
233 |
|
dim[3] = 3; |
234 |
< |
r1 = sqrt(CO_R0(co)*CO_R0(co) + |
234 |
> |
r3 = sqrt(CO_R0(co)*CO_R0(co) + |
235 |
|
urand(urind(ilhash(dim,4),i))* |
236 |
|
(CO_R1(co)*CO_R1(co) - CO_R0(co)*CO_R0(co))); |
237 |
|
dim[3] = 4; |
238 |
|
r2 = 2.*PI*urand(urind(ilhash(dim,4),i)); |
239 |
+ |
r1 = r3*cos(r2); |
240 |
+ |
r2 = r3*sin(r2); |
241 |
|
for (j = 0; j < 3; j++) |
242 |
< |
org[j] = CO_P0(co)[j] + |
243 |
< |
r1*cos(r2)*u[j] + r1*sin(r2)*v[j] |
233 |
< |
+ .001*co->ad[j]; |
242 |
> |
org[j] = CO_P0(co)[j] + r1*u[j] + r1*v[j] + |
243 |
> |
.001*co->ad[j]; |
244 |
|
|
245 |
|
/* send sample */ |
246 |
|
raysamp(distarr+dim[1]*nazi+dim[2], org, dir, rt); |
335 |
|
d2 = 2.*PI * azi; |
336 |
|
dv[0] = d1*cos(d2); |
337 |
|
dv[1] = d1*sin(d2); |
338 |
< |
dv[2] = sqrt(1. - d1*d1); |
338 |
> |
dv[2] = sqrt(1. - alt); |
339 |
|
} |