ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/image.c
(Generate patch)

Comparing ray/src/common/image.c (file contents):
Revision 2.34 by greg, Tue Mar 11 02:21:46 2008 UTC vs.
Revision 2.38 by greg, Fri Nov 16 00:14:19 2012 UTC

# Line 26 | Line 26 | static gethfunc gethview;
26  
27  
28   char *
29 < setview(v)              /* set hvec and vvec, return message on error */
30 < register VIEW  *v;
29 > setview(                /* set hvec and vvec, return message on error */
30 > VIEW  *v
31 > )
32   {
33          static char  ill_horiz[] = "illegal horizontal view size";
34          static char  ill_vert[] = "illegal vertical view size";
# Line 124 | Line 125 | register VIEW  *v;
125  
126  
127   void
128 < normaspect(va, ap, xp, yp)              /* fix pixel aspect or resolution */
129 < double  va;                     /* view aspect ratio */
130 < double  *ap;                    /* pixel aspect in (or out if 0) */
131 < int  *xp, *yp;                  /* x and y resolution in (or out if *ap!=0) */
128 > normaspect(                             /* fix pixel aspect or resolution */
129 > double  va,                     /* view aspect ratio */
130 > double  *ap,                    /* pixel aspect in (or out if 0) */
131 > int  *xp,
132 > int  *yp                        /* x and y resolution in (or out if *ap!=0) */
133 > )
134   {
135          if (*ap <= FTINY)
136                  *ap = va * *xp / *yp;           /* compute pixel aspect */
# Line 139 | Line 142 | int  *xp, *yp;                 /* x and y resolution in (or out if *
142  
143  
144   double
145 < viewray(orig, direc, v, x, y)           /* compute ray origin and direction */
146 < FVECT  orig, direc;
147 < register VIEW  *v;
148 < double  x, y;
145 > viewray(                                /* compute ray origin and direction */
146 > FVECT  orig,
147 > FVECT  direc,
148 > VIEW  *v,
149 > double  x,
150 > double  y
151 > )
152   {
153          double  d, z;
154          
# Line 215 | Line 221 | double  x, y;
221                  y *= sqrt(v->vn2);
222                  d = x*x + y*y;
223                  z = (1. - d)/(1. + d);
224 <                d = d <= FTINY*FTINY ? PI : sqrt((1.0 - z*z)/d);
225 <                x *= d;
220 <                y *= d;
224 >                x *= (1. + z);
225 >                y *= (1. + z);
226                  direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
227                  direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
228                  direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
# Line 231 | Line 236 | double  x, y;
236  
237  
238   void
239 < viewloc(ip, v, p)               /* find image location for point */
240 < FVECT  ip;
241 < register VIEW  *v;
242 < FVECT  p;
239 > viewloc(                        /* find image location for point */
240 > FVECT  ip,
241 > VIEW  *v,
242 > FVECT  p
243 > )
244   {
245          double  d, d2;
246          FVECT  disp;
# Line 301 | Line 307 | FVECT  p;
307                          return;
308                  if (d <= -(1.0-FTINY))
309                          return;         /* really an error */
310 <                d = sqrt(1.0 - d*d) / (1.0 + d);
311 <                ip[0] += DOT(disp,v->hvec)*d/sqrt(v->hn2);
306 <                ip[1] += DOT(disp,v->vvec)*d/sqrt(v->vn2);
310 >                ip[0] += DOT(disp,v->hvec)/((1. + d)*sqrt(v->hn2));
311 >                ip[1] += DOT(disp,v->vvec)/((1. + d)*sqrt(v->vn2));
312                  return;
313          }
314          ip[0] = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
# Line 312 | Line 317 | FVECT  p;
317  
318  
319   void
320 < pix2loc(loc, rp, px, py)        /* compute image location from pixel pos. */
321 < RREAL  loc[2];
322 < register RESOLU  *rp;
323 < int  px, py;
320 > pix2loc(                /* compute image location from pixel pos. */
321 > RREAL  loc[2],
322 > RESOLU  *rp,
323 > int  px,
324 > int  py
325 > )
326   {
327 <        register int  x, y;
327 >        int  x, y;
328  
329          if (rp->rt & YMAJOR) {
330                  x = px;
# Line 336 | Line 343 | int  px, py;
343  
344  
345   void
346 < loc2pix(pp, rp, lx, ly)         /* compute pixel pos. from image location */
347 < int  pp[2];
348 < register RESOLU  *rp;
349 < double  lx, ly;
346 > loc2pix(                        /* compute pixel pos. from image location */
347 > int  pp[2],
348 > RESOLU  *rp,
349 > double  lx,
350 > double  ly
351 > )
352   {
353 <        register int  x, y;
353 >        int  x, y;
354  
355 <        x = lx * rp->xr;
356 <        y = ly * rp->yr;
355 >        x = (int)(lx*rp->xr + .5 - (lx < 0.0));
356 >        y = (int)(ly*rp->yr + .5 - (ly < 0.0));
357 >
358          if (rp->rt & XDECR)
359                  x = rp->xr-1 - x;
360          if (rp->rt & YDECR)
# Line 360 | Line 370 | double  lx, ly;
370  
371  
372   int
373 < getviewopt(v, ac, av)                   /* process view argument */
374 < register VIEW  *v;
375 < int  ac;
376 < register char  *av[];
373 > getviewopt(                             /* process view argument */
374 > VIEW  *v,
375 > int  ac,
376 > char  *av[]
377 > )
378   {
379   #define check(c,l)      if ((av[0][c]&&av[0][c]!=' ') || \
380                          badarg(ac-1,av+1,l)) return(-1)
# Line 428 | Line 439 | register char  *av[];
439  
440  
441   int
442 < sscanview(vp, s)                        /* get view parameters from string */
443 < VIEW  *vp;
444 < register char  *s;
442 > sscanview(                              /* get view parameters from string */
443 > VIEW  *vp,
444 > char  *s
445 > )
446   {
447          int  ac;
448          char  *av[4];
# Line 462 | Line 474 | register char  *s;
474  
475  
476   void
477 < fprintview(vp, fp)                      /* write out view parameters */
478 < register VIEW  *vp;
479 < FILE  *fp;
477 > fprintview(                             /* write out view parameters */
478 > VIEW  *vp,
479 > FILE  *fp
480 > )
481   {
482          fprintf(fp, " -vt%c", vp->type);
483          fprintf(fp, " -vp %.6g %.6g %.6g", vp->vp[0], vp->vp[1], vp->vp[2]);
# Line 479 | Line 492 | FILE  *fp;
492  
493  
494   char *
495 < viewopt(vp)                             /* translate to minimal view string */
496 < register VIEW  *vp;
495 > viewopt(                                /* translate to minimal view string */
496 > VIEW  *vp
497 > )
498   {
499          static char  vwstr[128];
500 <        register char  *cp = vwstr;
500 >        char  *cp = vwstr;
501  
502          *cp = '\0';
503          if (vp->type != stdview.type) {
# Line 536 | Line 550 | register VIEW  *vp;
550  
551  
552   int
553 < isview(s)                               /* is this a view string? */
554 < char  *s;
553 > isview(                                 /* is this a view string? */
554 > char  *s
555 > )
556   {
557          static char  *altname[]={NULL,VIEWSTR,"rpict","rview","rvu","rpiece","pinterp",NULL};
558          extern char  *progname;
559 <        register char  *cp;
560 <        register char  **an;
559 >        char  *cp;
560 >        char  **an;
561                                          /* add program name to list */
562          if (altname[0] == NULL) {
563                  for (cp = progname; *cp; cp++)
# Line 583 | Line 598 | gethview(                              /* get view from header */
598  
599  
600   int
601 < viewfile(fname, vp, rp)                 /* get view from file */
602 < char  *fname;
603 < VIEW  *vp;
604 < RESOLU  *rp;
601 > viewfile(                               /* get view from file */
602 > char  *fname,
603 > VIEW  *vp,
604 > RESOLU  *rp
605 > )
606   {
607          struct myview   mvs;
608          FILE  *fp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines