--- ray/src/common/xf.c 1989/10/18 23:15:37 1.7 +++ ray/src/common/xf.c 1991/10/23 15:19:25 1.11 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1990 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -10,28 +10,28 @@ static char SCCSid[] = "$SunId$ LBL"; * 1/28/86 */ +#include "standard.h" -#define PI 3.14159265358979323846 #define d2r(a) ((PI/180.)*(a)) #define checkarg(a,n) if (av[i][a] || i+n >= ac) goto done int -xf(retmat, retsca, ac, av) /* get transform specification */ -double retmat[4][4]; -double *retsca; +xf(ret, ac, av) /* get transform specification */ +register XF *ret; int ac; char *av[]; { double atof(), sin(), cos(); - double xfmat[4][4], m4[4][4]; + MAT4 xfmat, m4; double xfsca, dtmp; int i, icnt; - setident4(retmat); - *retsca = 1.0; + setident4(ret->xfm); + ret->sca = 1.0; + icnt = 1; setident4(xfmat); xfsca = 1.0; @@ -108,14 +108,14 @@ char *av[]; case 'i': /* iterate */ checkarg(2,1); - icnt = atoi(av[++i]); while (icnt-- > 0) { - multmat4(retmat, retmat, xfmat); - *retsca *= xfsca; + multmat4(ret->xfm, ret->xfm, xfmat); + ret->sca *= xfsca; } + icnt = atoi(av[++i]); setident4(xfmat); xfsca = 1.0; - break; + continue; default: return(i); @@ -124,28 +124,29 @@ char *av[]; multmat4(xfmat, xfmat, m4); } done: - multmat4(retmat, retmat, xfmat); - *retsca *= xfsca; + while (icnt-- > 0) { + multmat4(ret->xfm, ret->xfm, xfmat); + ret->sca *= xfsca; + } return(i); } -#ifdef INVXF int -invxf(retmat, retsca, ac, av) /* invert transform specification */ -double retmat[4][4]; -double *retsca; +invxf(ret, ac, av) /* invert transform specification */ +register XF *ret; int ac; char *av[]; { double atof(), sin(), cos(); - double xfmat[4][4], m4[4][4]; + MAT4 xfmat, m4; double xfsca, dtmp; int i, icnt; - setident4(retmat); - *retsca = 1.0; + setident4(ret->xfm); + ret->sca = 1.0; + icnt = 1; setident4(xfmat); xfsca = 1.0; @@ -222,11 +223,11 @@ char *av[]; case 'i': /* iterate */ checkarg(2,1); - icnt = atoi(av[++i]); while (icnt-- > 0) { - multmat4(retmat, xfmat, retmat); - *retsca *= xfsca; + multmat4(ret->xfm, xfmat, ret->xfm); + ret->sca *= xfsca; } + icnt = atoi(av[++i]); setident4(xfmat); xfsca = 1.0; break; @@ -238,8 +239,20 @@ char *av[]; multmat4(xfmat, m4, xfmat); /* left multiply */ } done: - multmat4(retmat, xfmat, retmat); - *retsca *= xfsca; + while (icnt-- > 0) { + multmat4(ret->xfm, xfmat, ret->xfm); + ret->sca *= xfsca; + } return(i); } -#endif + + +int +fullxf(fx, ac, av) /* compute both forward and inverse */ +FULLXF *fx; +int ac; +char *av[]; +{ + xf(&fx->f, ac, av); + return(invxf(&fx->b, ac, av)); +}