--- ray/src/common/image.c 2012/10/27 03:01:21 2.37 +++ ray/src/common/image.c 2013/04/03 00:35:09 2.40 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: image.c,v 2.37 2012/10/27 03:01:21 greg Exp $"; +static const char RCSid[] = "$Id: image.c,v 2.40 2013/04/03 00:35:09 greg Exp $"; #endif /* * image.c - routines for image generation. @@ -33,7 +33,8 @@ VIEW *v static char ill_horiz[] = "illegal horizontal view size"; static char ill_vert[] = "illegal vertical view size"; - if (v->vaft < -FTINY || (v->vaft > FTINY && v->vaft <= v->vfore)) + if ((v->vfore < -FTINY) | (v->vaft < -FTINY) || + (v->vaft > FTINY) & (v->vaft <= v->vfore)) return("illegal fore/aft clipping plane"); if (v->vdist <= FTINY) @@ -169,9 +170,7 @@ double y direc[0] = v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; direc[1] = v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; direc[2] = v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; - orig[0] = v->vp[0] + v->vfore*direc[0]; - orig[1] = v->vp[1] + v->vfore*direc[1]; - orig[2] = v->vp[2] + v->vfore*direc[2]; + VSUM(orig, v->vp, direc, v->vfore); d = normalize(direc); return(v->vaft > FTINY ? (v->vaft - v->vfore)*d : 0.0); case VT_HEM: /* hemispherical fisheye */ @@ -182,9 +181,7 @@ double y direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; - orig[0] = v->vp[0] + v->vfore*direc[0]; - orig[1] = v->vp[1] + v->vfore*direc[1]; - orig[2] = v->vp[2] + v->vfore*direc[2]; + VSUM(orig, v->vp, direc, v->vfore); return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0); case VT_CYL: /* cylindrical panorama */ d = x * v->horiz * (PI/180.0); @@ -193,9 +190,7 @@ double y direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; - orig[0] = v->vp[0] + v->vfore*direc[0]; - orig[1] = v->vp[1] + v->vfore*direc[1]; - orig[2] = v->vp[2] + v->vfore*direc[2]; + VSUM(orig, v->vp, direc, v->vfore); d = normalize(direc); return(v->vaft > FTINY ? (v->vaft - v->vfore)*d : 0.0); case VT_ANG: /* angular fisheye */ @@ -212,24 +207,19 @@ double y direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; - orig[0] = v->vp[0] + v->vfore*direc[0]; - orig[1] = v->vp[1] + v->vfore*direc[1]; - orig[2] = v->vp[2] + v->vfore*direc[2]; + VSUM(orig, v->vp, direc, v->vfore); return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0); case VT_PLS: /* planispheric fisheye */ x *= sqrt(v->hn2); y *= sqrt(v->vn2); d = x*x + y*y; z = (1. - d)/(1. + d); - d = d <= FTINY*FTINY ? PI : sqrt((1.0 - z*z)/d); - x *= d; - y *= d; + x *= (1. + z); + y *= (1. + z); direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; - orig[0] = v->vp[0] + v->vfore*direc[0]; - orig[1] = v->vp[1] + v->vfore*direc[1]; - orig[2] = v->vp[2] + v->vfore*direc[2]; + VSUM(orig, v->vp, direc, v->vfore); return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0); } return(-1.0); @@ -308,9 +298,8 @@ FVECT p return; if (d <= -(1.0-FTINY)) return; /* really an error */ - d = sqrt(1.0 - d*d) / (1.0 + d); - ip[0] += DOT(disp,v->hvec)*d/sqrt(v->hn2); - ip[1] += DOT(disp,v->vvec)*d/sqrt(v->vn2); + ip[0] += DOT(disp,v->hvec)/((1. + d)*sqrt(v->hn2)); + ip[1] += DOT(disp,v->vvec)/((1. + d)*sqrt(v->vn2)); return; } ip[0] = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;