--- ray/src/rt/func.c 1991/06/17 08:28:26 1.16 +++ ray/src/rt/func.c 1991/07/17 10:09:24 1.20 @@ -33,16 +33,15 @@ OBJREC *m; register RAY *r; XF *bx; { - extern double l_arg(); + extern double l_arg(), l_erf(), l_erfc(); extern long eclock; static char *initfile = "rayinit.cal"; static long lastrno = -1; /* check to see if already set */ if (m == fobj && r->rno == lastrno) - return; + return(0); /* initialize if first call */ if (initfile != NULL) { - loadfunc(initfile); scompile("Dx=$1;Dy=$2;Dz=$3;", NULL, 0); scompile("Nx=$4;Ny=$5;Nz=$6;", NULL, 0); scompile("Px=$7;Py=$8;Pz=$9;", NULL, 0); @@ -52,7 +51,10 @@ XF *bx; scompile("Jx=$19;Jy=$20;Jz=$21;", NULL, 0); scompile("Kx=$22;Ky=$23;Kz=$24;", NULL, 0); funset("arg", 1, '=', l_arg); + funset("erf", 1, ':', l_erf); + funset("erfc", 1, ':', l_erfc); setnoisefuncs(); + loadfunc(initfile); initfile = NULL; } fobj = m; @@ -67,6 +69,7 @@ XF *bx; copystruct(&funcxf, bx); lastrno = r->rno; eclock++; /* notify expression evaluator */ + return(1); } @@ -96,8 +99,7 @@ RAY *r; } m->os = (char *)mxf; } - setmap(m, r, mxf); - return; + return(setmap(m, r, mxf)); memerr: error(SYSTEM, "out of memory in setfunc"); } @@ -137,6 +139,24 @@ l_arg() /* return nth real argument */ double +l_erf() /* error function */ +{ + extern double erf(); + + return(erf(argument(1))); +} + + +double +l_erfc() /* cumulative error function */ +{ + extern double erfc(); + + return(erfc(argument(1))); +} + + +double chanvalue(n) /* return channel n to calcomp */ register int n; { @@ -175,8 +195,10 @@ register int n; return(sum * funcxf.sca); } - if (n == 10) /* dot product */ - return(fray->rod); + if (n == 10) /* dot product (range [-1,1]) */ + return( fray->rod <= -1.0 ? -1.0 : + fray->rod >= 1.0 ? 1.0 : + fray->rod ); if (n == 11) /* scale */ return(funcxf.sca);