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.10 by greg, Thu Aug 24 11:55:03 1995 UTC vs.
Revision 2.13 by gregl, Tue Dec 9 16:41:03 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 6 | Line 6 | static char SCCSid[] = "$SunId$ LBL";
6  
7   /*
8   *  image.c - routines for image generation.
9 *
10 *     10/17/85
9   */
10  
11   #include  "standard.h"
# Line 18 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "paths.h"
18  
19 + #define  FEQ(x,y)       (fabs((x)-(y)) <= FTINY)
20 + #define  VEQ(v,w)       (FEQ((v)[0],(w)[0]) && FEQ((v)[1],(w)[1]) \
21 +                                && FEQ((v)[2],(w)[2]))
22 +
23   VIEW  stdview = STDVIEW;                /* default view parameters */
24  
25  
# Line 203 | Line 205 | FVECT  ip;
205   register VIEW  *v;
206   FVECT  p;
207   {
208 <        double  d;
208 >        double  d, d2;
209          FVECT  disp;
210  
211          disp[0] = p[0] - v->vp[0];
# Line 216 | Line 218 | FVECT  p;
218                  break;
219          case VT_PER:                    /* perspective view */
220                  d = DOT(disp,v->vdir);
221 <                ip[2] = sqrt(DOT(disp,disp));
221 >                ip[2] = VLEN(disp);
222                  if (d < 0.0) {          /* fold pyramid */
223                          ip[2] = -ip[2];
224                          d = -d;
# Line 238 | Line 240 | FVECT  p;
240                  ip[2] -= v->vfore;
241                  break;
242          case VT_CYL:                    /* cylindrical panorama */
241                ip[2] = DOT(disp,v->vdir);
243                  d = DOT(disp,v->hvec);
244 <                ip[0] = 180.0/PI * atan2(d,ip[2]) / v->horiz + 0.5 - v->hoff;
245 <                ip[1] = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
244 >                d2 = DOT(disp,v->vdir);
245 >                ip[0] = 180.0/PI * atan2(d,d2) / v->horiz + 0.5 - v->hoff;
246 >                d = 1.0/sqrt(d*d + d2*d2);
247 >                ip[1] = DOT(disp,v->vvec)*d/v->vn2 + 0.5 - v->voff;
248 >                ip[2] = VLEN(disp);
249                  if (v->vfore > FTINY)
250 <                        ip[2] = sqrt(DOT(disp,disp)) *
247 <                                (1.0 - v->vfore/sqrt(d*d + ip[2]*ip[2]));
248 <                else
249 <                        ip[2] = sqrt(DOT(disp,disp));
250 >                        ip[2] *= (1.0 - v->vfore*d);
251                  return;
252          case VT_ANG:                    /* angular fisheye */
253                  ip[0] = 0.5 - v->hoff;
# Line 393 | Line 394 | register char  *s;
394          int  nvopts = 0;
395  
396          if (*s != '-')
397 <                s = sskip(s);
397 >                s = sskip2(s,1);
398          while (*s) {
399                  ac = 0;
400                  do {
# Line 425 | Line 426 | FILE  *fp;
426          fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert);
427          fprintf(fp, " -vo %.6g -va %.6g", vp->vfore, vp->vaft);
428          fprintf(fp, " -vs %.6g -vl %.6g", vp->hoff, vp->voff);
429 + }
430 +
431 +
432 + char *
433 + viewopt(vp)                             /* translate to minimal view string */
434 + register VIEW  *vp;
435 + {
436 +        static char  vwstr[128];
437 +        register char  *cp = vwstr;
438 +
439 +        if (vp->type != stdview.type) {
440 +                sprintf(cp, " -vt%c", vp->type);
441 +                cp += strlen(cp);
442 +        }
443 +        if (!VEQ(vp->vp,stdview.vp)) {
444 +                sprintf(cp, " -vp %.6g %.6g %.6g",
445 +                                vp->vp[0], vp->vp[1], vp->vp[2]);
446 +                cp += strlen(cp);
447 +        }
448 +        if (!VEQ(vp->vdir,stdview.vdir)) {
449 +                sprintf(cp, " -vd %.6g %.6g %.6g",
450 +                                vp->vdir[0], vp->vdir[1], vp->vdir[2]);
451 +                cp += strlen(cp);
452 +        }
453 +        if (!VEQ(vp->vup,stdview.vup)) {
454 +                sprintf(cp, " -vu %.6g %.6g %.6g",
455 +                                vp->vup[0], vp->vup[1], vp->vup[2]);
456 +                cp += strlen(cp);
457 +        }
458 +        if (!FEQ(vp->horiz,stdview.horiz)) {
459 +                sprintf(cp, " -vh %.6g", vp->horiz);
460 +                cp += strlen(cp);
461 +        }
462 +        if (!FEQ(vp->vert,stdview.vert)) {
463 +                sprintf(cp, " -vv %.6g", vp->vert);
464 +                cp += strlen(cp);
465 +        }
466 +        if (!FEQ(vp->vfore,stdview.vfore)) {
467 +                sprintf(cp, " -vo %.6g", vp->vfore);
468 +                cp += strlen(cp);
469 +        }
470 +        if (!FEQ(vp->vaft,stdview.vaft)) {
471 +                sprintf(cp, " -va %.6g", vp->vaft);
472 +                cp += strlen(cp);
473 +        }
474 +        if (!FEQ(vp->hoff,stdview.hoff)) {
475 +                sprintf(cp, " -vs %.6g", vp->hoff);
476 +                cp += strlen(cp);
477 +        }
478 +        if (!FEQ(vp->voff,stdview.voff)) {
479 +                sprintf(cp, " -vl %.6g", vp->voff);
480 +                cp += strlen(cp);
481 +        }
482 +        return(vwstr);
483   }
484  
485  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines