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.15 by gwlarson, Fri Feb 26 12:24:07 1999 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 28 | Line 30 | register VIEW  *v;
30          static char  ill_horiz[] = "illegal horizontal view size";
31          static char  ill_vert[] = "illegal vertical view size";
32          
33 <        if (v->vfore < -FTINY || v->vaft < -FTINY ||
32 <                        (v->vaft > FTINY && v->vaft <= v->vfore))
33 >        if (v->vaft < -FTINY || (v->vaft > FTINY && v->vaft <= v->vfore))
34                  return("illegal fore/aft clipping plane");
35  
36          if (normalize(v->vdir) == 0.0)          /* normalize direction */
# Line 203 | Line 204 | FVECT  ip;
204   register VIEW  *v;
205   FVECT  p;
206   {
207 <        double  d;
207 >        double  d, d2;
208          FVECT  disp;
209  
210          disp[0] = p[0] - v->vp[0];
# Line 216 | Line 217 | FVECT  p;
217                  break;
218          case VT_PER:                    /* perspective view */
219                  d = DOT(disp,v->vdir);
220 <                ip[2] = sqrt(DOT(disp,disp));
220 >                ip[2] = VLEN(disp);
221                  if (d < 0.0) {          /* fold pyramid */
222                          ip[2] = -ip[2];
223                          d = -d;
# Line 238 | Line 239 | FVECT  p;
239                  ip[2] -= v->vfore;
240                  break;
241          case VT_CYL:                    /* cylindrical panorama */
241                ip[2] = DOT(disp,v->vdir);
242                  d = DOT(disp,v->hvec);
243 <                ip[0] = 180.0/PI * atan2(d,ip[2]) / v->horiz + 0.5 - v->hoff;
244 <                ip[1] = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
245 <                if (v->vfore > FTINY)
246 <                        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));
243 >                d2 = DOT(disp,v->vdir);
244 >                ip[0] = 180.0/PI * atan2(d,d2) / v->horiz + 0.5 - v->hoff;
245 >                d = 1.0/sqrt(d*d + d2*d2);
246 >                ip[1] = DOT(disp,v->vvec)*d/v->vn2 + 0.5 - v->voff;
247 >                ip[2] = VLEN(disp);
248 >                ip[2] *= (1.0 - v->vfore*d);
249                  return;
250          case VT_ANG:                    /* angular fisheye */
251                  ip[0] = 0.5 - v->hoff;
# Line 393 | Line 392 | register char  *s;
392          int  nvopts = 0;
393  
394          if (*s != '-')
395 <                s = sskip(s);
395 >                s = sskip2(s,1);
396          while (*s) {
397                  ac = 0;
398                  do {
# Line 428 | Line 427 | FILE  *fp;
427   }
428  
429  
430 + char *
431 + viewopt(vp)                             /* translate to minimal view string */
432 + register VIEW  *vp;
433 + {
434 +        static char  vwstr[128];
435 +        register char  *cp = vwstr;
436 +
437 +        if (vp->type != stdview.type) {
438 +                sprintf(cp, " -vt%c", vp->type);
439 +                cp += strlen(cp);
440 +        }
441 +        if (!VEQ(vp->vp,stdview.vp)) {
442 +                sprintf(cp, " -vp %.6g %.6g %.6g",
443 +                                vp->vp[0], vp->vp[1], vp->vp[2]);
444 +                cp += strlen(cp);
445 +        }
446 +        if (!VEQ(vp->vdir,stdview.vdir)) {
447 +                sprintf(cp, " -vd %.6g %.6g %.6g",
448 +                                vp->vdir[0], vp->vdir[1], vp->vdir[2]);
449 +                cp += strlen(cp);
450 +        }
451 +        if (!VEQ(vp->vup,stdview.vup)) {
452 +                sprintf(cp, " -vu %.6g %.6g %.6g",
453 +                                vp->vup[0], vp->vup[1], vp->vup[2]);
454 +                cp += strlen(cp);
455 +        }
456 +        if (!FEQ(vp->horiz,stdview.horiz)) {
457 +                sprintf(cp, " -vh %.6g", vp->horiz);
458 +                cp += strlen(cp);
459 +        }
460 +        if (!FEQ(vp->vert,stdview.vert)) {
461 +                sprintf(cp, " -vv %.6g", vp->vert);
462 +                cp += strlen(cp);
463 +        }
464 +        if (!FEQ(vp->vfore,stdview.vfore)) {
465 +                sprintf(cp, " -vo %.6g", vp->vfore);
466 +                cp += strlen(cp);
467 +        }
468 +        if (!FEQ(vp->vaft,stdview.vaft)) {
469 +                sprintf(cp, " -va %.6g", vp->vaft);
470 +                cp += strlen(cp);
471 +        }
472 +        if (!FEQ(vp->hoff,stdview.hoff)) {
473 +                sprintf(cp, " -vs %.6g", vp->hoff);
474 +                cp += strlen(cp);
475 +        }
476 +        if (!FEQ(vp->voff,stdview.voff)) {
477 +                sprintf(cp, " -vl %.6g", vp->voff);
478 +                cp += strlen(cp);
479 +        }
480 +        return(vwstr);
481 + }
482 +
483 +
484   int
485   isview(s)                               /* is this a view string? */
486   char  *s;
# Line 463 | Line 516 | struct myview {
516   };
517  
518  
519 < static
519 > static int
520   gethview(s, v)                          /* get view from header */
521   char  *s;
522   register struct myview  *v;
523   {
524          if (isview(s) && sscanview(v->hv, s) > 0)
525                  v->ok++;
526 +        return(0);
527   }
528  
529  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines