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.7 by greg, Tue Dec 20 20:15:04 1994 UTC vs.
Revision 2.11 by greg, Wed Jan 10 19:25:57 1996 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 63 | Line 65 | register VIEW  *v;
65                  v->hn2 = 2.0 * tan(v->horiz*(PI/180.0/2.0));
66                  v->vn2 = 2.0 * tan(v->vert*(PI/180.0/2.0));
67                  break;
68 +        case VT_CYL:                            /* cylindrical panorama */
69 +                if (v->horiz > 360.0+FTINY)
70 +                        return(ill_horiz);
71 +                if (v->vert >= 180.0-FTINY)
72 +                        return(ill_vert);
73 +                v->hn2 = v->horiz * (PI/180.0);
74 +                v->vn2 = 2.0 * tan(v->vert*(PI/180.0/2.0));
75 +                break;
76          case VT_ANG:                            /* angular fisheye */
77                  if (v->horiz > 360.0+FTINY)
78                          return(ill_horiz);
79                  if (v->vert > 360.0+FTINY)
80                          return(ill_vert);
81 <                v->hn2 = v->horiz / 90.0;
82 <                v->vn2 = v->vert / 90.0;
81 >                v->hn2 = v->horiz * (PI/180.0);
82 >                v->vn2 = v->vert * (PI/180.0);
83                  break;
84          case VT_HEM:                            /* hemispherical fisheye */
85                  if (v->horiz > 180.0+FTINY)
# Line 83 | Line 93 | register VIEW  *v;
93                  return("unknown view type");
94          }
95          if (v->type != VT_ANG) {
96 <                v->hvec[0] *= v->hn2;
97 <                v->hvec[1] *= v->hn2;
98 <                v->hvec[2] *= v->hn2;
96 >                if (v->type != VT_CYL) {
97 >                        v->hvec[0] *= v->hn2;
98 >                        v->hvec[1] *= v->hn2;
99 >                        v->hvec[2] *= v->hn2;
100 >                }
101                  v->vvec[0] *= v->vn2;
102                  v->vvec[1] *= v->vn2;
103                  v->vvec[2] *= v->vn2;
# Line 131 | Line 143 | double  x, y;
143                  orig[2] = v->vp[2] + v->vfore*v->vdir[2]
144                                  + x*v->hvec[2] + y*v->vvec[2];
145                  VCOPY(direc, v->vdir);
146 <                return(v->vaft - v->vfore);
146 >                return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0);
147          case VT_PER:                    /* perspective view */
148                  direc[0] = v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
149                  direc[1] = v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
# Line 140 | Line 152 | double  x, y;
152                  orig[1] = v->vp[1] + v->vfore*direc[1];
153                  orig[2] = v->vp[2] + v->vfore*direc[2];
154                  d = normalize(direc);
155 <                return((v->vaft - v->vfore)*d);
155 >                return(v->vaft > FTINY ? (v->vaft - v->vfore)*d : 0.0);
156          case VT_HEM:                    /* hemispherical fisheye */
157                  z = 1.0 - x*x*v->hn2 - y*y*v->vn2;
158                  if (z < 0.0)
# Line 152 | Line 164 | double  x, y;
164                  orig[0] = v->vp[0] + v->vfore*direc[0];
165                  orig[1] = v->vp[1] + v->vfore*direc[1];
166                  orig[2] = v->vp[2] + v->vfore*direc[2];
167 <                return(v->vaft - v->vfore);
167 >                return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0);
168 >        case VT_CYL:                    /* cylindrical panorama */
169 >                d = x * v->horiz * (PI/180.0);
170 >                z = cos(d);
171 >                x = sin(d);
172 >                direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
173 >                direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
174 >                direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
175 >                orig[0] = v->vp[0] + v->vfore*direc[0];
176 >                orig[1] = v->vp[1] + v->vfore*direc[1];
177 >                orig[2] = v->vp[2] + v->vfore*direc[2];
178 >                d = normalize(direc);
179 >                return(v->vaft > FTINY ? (v->vaft - v->vfore)*d : 0.0);
180          case VT_ANG:                    /* angular fisheye */
181                  x *= v->horiz/180.0;
182                  y *= v->vert/180.0;
# Line 170 | Line 194 | double  x, y;
194                  orig[0] = v->vp[0] + v->vfore*direc[0];
195                  orig[1] = v->vp[1] + v->vfore*direc[1];
196                  orig[2] = v->vp[2] + v->vfore*direc[2];
197 <                return(v->vaft - v->vfore);
197 >                return(v->vaft > FTINY ? v->vaft - v->vfore : 0.0);
198          }
199          return(-1.0);
200   }
# Line 215 | Line 239 | FVECT  p;
239                          ip[2] = d;
240                  ip[2] -= v->vfore;
241                  break;
242 +        case VT_CYL:                    /* cylindrical panorama */
243 +                ip[2] = DOT(disp,v->vdir);
244 +                d = DOT(disp,v->hvec);
245 +                ip[0] = 180.0/PI * atan2(d,ip[2]) / v->horiz + 0.5 - v->hoff;
246 +                ip[1] = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
247 +                if (v->vfore > FTINY)
248 +                        ip[2] = sqrt(DOT(disp,disp)) *
249 +                                (1.0 - v->vfore/sqrt(d*d + ip[2]*ip[2]));
250 +                else
251 +                        ip[2] = sqrt(DOT(disp,disp));
252 +                return;
253          case VT_ANG:                    /* angular fisheye */
254                  ip[0] = 0.5 - v->hoff;
255                  ip[1] = 0.5 - v->voff;
# Line 224 | Line 259 | FVECT  p;
259                          return;
260                  if (d <= -(1.0-FTINY)) {
261                          ip[0] += 180.0/v->horiz;
227                        ip[1] += 180.0/v->vert;
262                          return;
263                  }
264                  d = acos(d)/PI / sqrt(1.0 - d*d);
# Line 393 | Line 427 | FILE  *fp;
427          fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert);
428          fprintf(fp, " -vo %.6g -va %.6g", vp->vfore, vp->vaft);
429          fprintf(fp, " -vs %.6g -vl %.6g", vp->hoff, vp->voff);
430 + }
431 +
432 +
433 + char *
434 + viewopt(vp)                             /* translate to minimal view string */
435 + register VIEW  *vp;
436 + {
437 +        static char  vwstr[128];
438 +        register char  *cp = vwstr;
439 +
440 +        if (vp->type != stdview.type) {
441 +                sprintf(cp, " -vt%c", vp->type);
442 +                cp += strlen(cp);
443 +        }
444 +        if (!VEQ(vp->vp,stdview.vp)) {
445 +                sprintf(cp, " -vp %.6g %.6g %.6g",
446 +                                vp->vp[0], vp->vp[1], vp->vp[2]);
447 +                cp += strlen(cp);
448 +        }
449 +        if (!VEQ(vp->vdir,stdview.vdir)) {
450 +                sprintf(cp, " -vd %.6g %.6g %.6g",
451 +                                vp->vdir[0], vp->vdir[1], vp->vdir[2]);
452 +                cp += strlen(cp);
453 +        }
454 +        if (!VEQ(vp->vup,stdview.vup)) {
455 +                sprintf(cp, " -vu %.6g %.6g %.6g",
456 +                                vp->vup[0], vp->vup[1], vp->vup[2]);
457 +                cp += strlen(cp);
458 +        }
459 +        if (!FEQ(vp->horiz,stdview.horiz)) {
460 +                sprintf(cp, " -vh %.6g", vp->horiz);
461 +                cp += strlen(cp);
462 +        }
463 +        if (!FEQ(vp->vert,stdview.vert)) {
464 +                sprintf(cp, " -vv %.6g", vp->vert);
465 +                cp += strlen(cp);
466 +        }
467 +        if (!FEQ(vp->vfore,stdview.vfore)) {
468 +                sprintf(cp, " -vo %.6g", vp->vfore);
469 +                cp += strlen(cp);
470 +        }
471 +        if (!FEQ(vp->vaft,stdview.vaft)) {
472 +                sprintf(cp, " -va %.6g", vp->vaft);
473 +                cp += strlen(cp);
474 +        }
475 +        if (!FEQ(vp->hoff,stdview.hoff)) {
476 +                sprintf(cp, " -vs %.6g", vp->hoff);
477 +                cp += strlen(cp);
478 +        }
479 +        if (!FEQ(vp->voff,stdview.voff)) {
480 +                sprintf(cp, " -vl %.6g", vp->voff);
481 +                cp += strlen(cp);
482 +        }
483 +        return(vwstr);
484   }
485  
486  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines