--- ray/src/util/rpiece.c 2004/03/26 21:36:20 2.43 +++ ray/src/util/rpiece.c 2009/02/07 05:40:47 2.50 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpiece.c,v 2.43 2004/03/26 21:36:20 schorsch Exp $"; +static const char RCSid[] = "$Id: rpiece.c,v 2.50 2009/02/07 05:40:47 greg Exp $"; #endif /* * Generate sections of a picture. @@ -9,11 +9,13 @@ static const char RCSid[] = "$Id: rpiece.c,v 2.43 2004 #include #include #include -#include #include "platform.h" -#include "rtio.h" -#include "rtmisc.h" +#ifndef NON_POSIX /* XXX need abstraction for process management */ + #include +#endif + +#include "standard.h" #include "color.h" #include "view.h" #include "rtprocess.h" @@ -106,7 +108,7 @@ main( while ((rval = expandarg(&argc, &argv, i)) > 0) ; if (rval < 0) { - fprintf(stderr, "%s: cannot expand '%s'", + fprintf(stderr, "%s: cannot expand '%s'\n", argv[0], argv[i]); exit(1); } @@ -247,6 +249,10 @@ init( /* set up output file and start rpict */ /* compute piece size */ hres /= hmult; vres /= vmult; + if (hres <= 0 || vres <= 0) { + fprintf(stderr, "%s: illegal resolution/subdivision\n", progname); + exit(1); + } normaspect(viewaspect(&ourview)*hmult/vmult, &pixaspect, &hres, &vres); sprintf(hrbuf, "%d", hres); rpargv[rpargc++] = "-x"; rpargv[rpargc++] = hrbuf; @@ -432,10 +438,10 @@ rpiece(void) /* render picture piece by piece */ pview = ourview; switch (ourview.type) { case VT_PER: - pview.horiz = 2.*180./PI*atan( - tan(PI/180./2.*ourview.horiz)/hmult ); - pview.vert = 2.*180./PI*atan( - tan(PI/180./2.*ourview.vert)/vmult ); + pview.horiz = (2.*180./PI)*atan( + tan((PI/180./2.)*ourview.horiz)/hmult ); + pview.vert = (2.*180./PI)*atan( + tan((PI/180./2.)*ourview.vert)/vmult ); break; case VT_PAR: case VT_ANG: @@ -444,14 +450,26 @@ rpiece(void) /* render picture piece by piece */ break; case VT_CYL: pview.horiz = ourview.horiz / hmult; - pview.vert = 2.*180./PI*atan( - tan(PI/180./2.*ourview.vert)/vmult ); + pview.vert = (2.*180./PI)*atan( + tan((PI/180./2.)*ourview.vert)/vmult ); break; case VT_HEM: - pview.horiz = 2.*180./PI*asin( - sin(PI/180./2.*ourview.horiz)/hmult ); - pview.vert = 2.*180./PI*asin( - sin(PI/180./2.*ourview.vert)/vmult ); + pview.horiz = (2.*180./PI)*asin( + sin((PI/180./2.)*ourview.horiz)/hmult ); + pview.vert = (2.*180./PI)*asin( + sin((PI/180./2.)*ourview.vert)/vmult ); + break; + case VT_PLS: + pview.horiz = sin((PI/180./2.)*ourview.horiz) / + (1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult; + pview.horiz *= pview.horiz; + pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) / + (1. + pview.horiz)); + pview.vert = sin((PI/180./2.)*ourview.vert) / + (1.0 + cos((PI/180./2.)*ourview.vert)) / vmult; + pview.vert *= pview.vert; + pview.vert = (2.*180./PI)*acos((1. - pview.vert) / + (1. + pview.vert)); break; default: fprintf(stderr, "%s: unknown view type '-vt%c'\n",