| 33 |
|
register RAY *r; |
| 34 |
|
XF *bx; |
| 35 |
|
{ |
| 36 |
< |
extern double l_noise3(), l_noise3a(), l_noise3b(), l_noise3c(); |
| 37 |
< |
extern double l_hermite(), l_fnoise3(), l_arg(); |
| 36 |
> |
extern double l_arg(), l_erf(), l_erfc(); |
| 37 |
|
extern long eclock; |
| 38 |
|
static char *initfile = "rayinit.cal"; |
| 39 |
+ |
static long lastrno = -1; |
| 40 |
+ |
/* check to see if already set */ |
| 41 |
+ |
if (m == fobj && r->rno == lastrno) |
| 42 |
+ |
return(0); |
| 43 |
|
/* initialize if first call */ |
| 44 |
|
if (initfile != NULL) { |
| 45 |
|
loadfunc(initfile); |
| 52 |
|
scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0); |
| 53 |
|
scompile("Kx=$22;Ky=$23;Kz=$24;", NULL, 0); |
| 54 |
|
funset("arg", 1, '=', l_arg); |
| 55 |
< |
funset("noise3", 3, ':', l_noise3); |
| 56 |
< |
funset("noise3a", 3, ':', l_noise3a); |
| 57 |
< |
funset("noise3b", 3, ':', l_noise3b); |
| 55 |
< |
funset("noise3c", 3, ':', l_noise3c); |
| 56 |
< |
funset("hermite", 5, ':', l_hermite); |
| 57 |
< |
funset("fnoise3", 3, ':', l_fnoise3); |
| 55 |
> |
funset("erf", 1, ':', l_erf); |
| 56 |
> |
funset("erfc", 1, ':', l_erfc); |
| 57 |
> |
setnoisefuncs(); |
| 58 |
|
initfile = NULL; |
| 59 |
|
} |
| 60 |
|
fobj = m; |
| 67 |
|
copystruct(&funcxf, &r->rox->b); |
| 68 |
|
else |
| 69 |
|
copystruct(&funcxf, bx); |
| 70 |
+ |
lastrno = r->rno; |
| 71 |
|
eclock++; /* notify expression evaluator */ |
| 72 |
+ |
return(1); |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 99 |
|
} |
| 100 |
|
m->os = (char *)mxf; |
| 101 |
|
} |
| 102 |
< |
setmap(m, r, mxf); |
| 101 |
< |
return; |
| 102 |
> |
return(setmap(m, r, mxf)); |
| 103 |
|
memerr: |
| 104 |
|
error(SYSTEM, "out of memory in setfunc"); |
| 105 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
double |
| 142 |
+ |
l_erf() /* error function */ |
| 143 |
+ |
{ |
| 144 |
+ |
extern double erf(); |
| 145 |
+ |
|
| 146 |
+ |
return(erf(argument(1))); |
| 147 |
+ |
} |
| 148 |
+ |
|
| 149 |
+ |
|
| 150 |
+ |
double |
| 151 |
+ |
l_erfc() /* cumulative error function */ |
| 152 |
+ |
{ |
| 153 |
+ |
extern double erfc(); |
| 154 |
+ |
|
| 155 |
+ |
return(erfc(argument(1))); |
| 156 |
+ |
} |
| 157 |
+ |
|
| 158 |
+ |
|
| 159 |
+ |
double |
| 160 |
|
chanvalue(n) /* return channel n to calcomp */ |
| 161 |
|
register int n; |
| 162 |
|
{ |
| 195 |
|
return(sum * funcxf.sca); |
| 196 |
|
|
| 197 |
|
} |
| 198 |
< |
if (n == 10) /* dot product */ |
| 199 |
< |
return(fray->rod); |
| 198 |
> |
if (n == 10) /* dot product (range [-1,1]) */ |
| 199 |
> |
return( fray->rod <= -1.0 ? -1.0 : |
| 200 |
> |
fray->rod >= 1.0 ? 1.0 : |
| 201 |
> |
fray->rod ); |
| 202 |
|
|
| 203 |
|
if (n == 11) /* scale */ |
| 204 |
|
return(funcxf.sca); |