| 23 |
|
#define LCALSUF 4 |
| 24 |
|
|
| 25 |
|
XF unitxf = { /* identity transform */ |
| 26 |
< |
1.0, 0.0, 0.0, 0.0, |
| 27 |
< |
0.0, 1.0, 0.0, 0.0, |
| 28 |
< |
0.0, 0.0, 1.0, 0.0, |
| 29 |
< |
0.0, 0.0, 0.0, 1.0, |
| 26 |
> |
{{1.0, 0.0, 0.0, 0.0}, |
| 27 |
> |
{0.0, 1.0, 0.0, 0.0}, |
| 28 |
> |
{0.0, 0.0, 1.0, 0.0}, |
| 29 |
> |
{0.0, 0.0, 0.0, 1.0}}, |
| 30 |
|
1.0 |
| 31 |
|
}; |
| 32 |
|
|
| 54 |
|
/* check to see if done already */ |
| 55 |
|
if ((f = (MFUNC *)m->os) != NULL) |
| 56 |
|
return(f); |
| 57 |
+ |
fobj = NULL; fray = NULL; |
| 58 |
|
if (initfile[0]) { /* initialize on first call */ |
| 59 |
|
setcontext(""); |
| 60 |
|
scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0); |
| 61 |
|
scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0); |
| 62 |
|
scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0); |
| 63 |
< |
scompile("T=$10;Rdot=$11;", NULL, 0); |
| 63 |
> |
scompile("T=$10;Ts=$25;Rdot=$11;", NULL, 0); |
| 64 |
|
scompile("S=$12;Tx=$13;Ty=$14;Tz=$15;", NULL, 0); |
| 65 |
|
scompile("Ix=$16;Iy=$17;Iz=$18;", NULL, 0); |
| 66 |
|
scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0); |
| 212 |
|
extern double argument(); |
| 213 |
|
register int n; |
| 214 |
|
|
| 215 |
+ |
if (fobj == NULL) |
| 216 |
+ |
syntax("arg(n) used in constant expression"); |
| 217 |
+ |
|
| 218 |
|
n = argument(1) + .5; /* round to integer */ |
| 219 |
|
|
| 220 |
|
if (n < 1) |
| 253 |
|
double sum; |
| 254 |
|
register RAY *r; |
| 255 |
|
|
| 256 |
+ |
if (fray == NULL) |
| 257 |
+ |
syntax("ray parameter used in constant expression"); |
| 258 |
+ |
|
| 259 |
|
if (--n < 0) |
| 260 |
|
goto badchan; |
| 261 |
|
|
| 280 |
|
fray->rop[2]*funcxf.xfm[2][n-6] + |
| 281 |
|
funcxf.xfm[3][n-6] ); |
| 282 |
|
|
| 283 |
< |
if (n == 9) { /* distance */ |
| 277 |
< |
|
| 283 |
> |
if (n == 9) { /* total distance */ |
| 284 |
|
sum = fray->rot; |
| 285 |
|
for (r = fray->parent; r != NULL; r = r->parent) |
| 286 |
|
sum += r->rot; |
| 287 |
|
return(sum * funcxf.sca); |
| 288 |
|
|
| 289 |
|
} |
| 290 |
+ |
|
| 291 |
|
if (n == 10) /* dot product (range [-1,1]) */ |
| 292 |
|
return( fray->rod <= -1.0 ? -1.0 : |
| 293 |
|
fray->rod >= 1.0 ? 1.0 : |
| 307 |
|
|
| 308 |
|
if (n < 24) /* k unit vector */ |
| 309 |
|
return(funcxf.xfm[2][n-21] / funcxf.sca); |
| 310 |
+ |
|
| 311 |
+ |
if (n == 24) { /* single ray (shadow) distance */ |
| 312 |
+ |
sum = fray->rot; |
| 313 |
+ |
for (r = fray->parent; r != NULL && r->crtype&SHADOW; |
| 314 |
+ |
r = r->parent) |
| 315 |
+ |
sum += r->rot; |
| 316 |
+ |
return(sum * funcxf.sca); |
| 317 |
+ |
} |
| 318 |
|
badchan: |
| 319 |
|
error(USER, "illegal channel number"); |
| 320 |
|
} |