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 1.12 by greg, Sat Oct 13 20:56:01 1990 UTC vs.
Revision 1.16 by greg, Thu Nov 7 11:04:00 1991 UTC

# Line 27 | Line 27 | register VIEW  *v;
27          if (normalize(v->vdir) == 0.0)          /* normalize direction */
28                  return("zero view direction");
29  
30 +        if (normalize(v->vup) == 0.0)           /* normalize view up */
31 +                return("zero view up vector");
32 +
33          fcross(v->hvec, v->vdir, v->vup);       /* compute horiz dir */
34  
35          if (normalize(v->hvec) == 0.0)
36 <                return("illegal view up vector");
36 >                return("view up parallel to view direction");
37  
38          fcross(v->vvec, v->hvec, v->vdir);      /* compute vert dir */
39  
# Line 71 | Line 74 | register VIEW  *v;
74          default:
75                  return("unknown view type");
76          }
77 <        if (v->type == VT_PAR || v->type == VT_PER) {
77 >        if (v->type != VT_ANG) {
78                  v->hvec[0] *= v->hn2;
79                  v->hvec[1] *= v->hn2;
80                  v->hvec[2] *= v->hn2;
# Line 125 | Line 128 | double  x, y;
128                  normalize(direc);
129                  return(0);
130          case VT_HEM:                    /* hemispherical fisheye */
131 <                x *= v->horiz/90.0;
129 <                y *= v->vert/90.0;
130 <                z = 1.0 - x*x - y*y;
131 >                z = 1.0 - x*x*v->hn2 - y*y*v->vn2;
132                  if (z < 0.0)
133                          return(-1);
134                  z = sqrt(z);
# Line 177 | Line 178 | FVECT  p;
178          case VT_PAR:                    /* parallel view */
179                  if (zp != NULL)
180                          *zp = DOT(disp,v->vdir);
181 <                *xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
181 <                *yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
182 <                return;
181 >                break;
182          case VT_PER:                    /* perspective view */
183                  d = DOT(disp,v->vdir);
184                  if (zp != NULL) {
# Line 195 | Line 194 | FVECT  p;
194                          disp[1] *= d;
195                          disp[2] *= d;
196                  }
197 <                *xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
199 <                *yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
200 <                return;
197 >                break;
198          case VT_HEM:                    /* hemispherical fisheye */
199                  d = normalize(disp);
200                  if (zp != NULL) {
# Line 206 | Line 203 | FVECT  p;
203                          else
204                                  *zp = d;
205                  }
206 <                *xp = DOT(disp,v->hvec)*90.0/v->horiz + 0.5 - v->hoff;
210 <                *yp = DOT(disp,v->vvec)*90.0/v->vert + 0.5 - v->voff;
211 <                return;
206 >                break;
207          case VT_ANG:                    /* angular fisheye */
208                  d = normalize(disp);
209                  if (zp != NULL)
# Line 228 | Line 223 | FVECT  p;
223                  *yp += DOT(disp,v->vvec)*d*180.0/v->vert;
224                  return;
225          }
226 +        *xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
227 +        *yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
228   }
229  
230  
# Line 237 | Line 234 | register VIEW  *v;
234   int  ac;
235   register char  *av[];
236   {
237 < #define check(c,n)      if ((av[0][c]&&av[0][c]!=' ') || n>=ac) return(-1)
237 > #define check(c,l)      if ((av[0][c]&&av[0][c]!=' ') || \
238 >                        badarg(ac-1,av+1,l)) return(-1)
239          extern double  atof();
240  
241          if (ac <= 0 || av[0][0] != '-' || av[0][1] != 'v')
# Line 246 | Line 244 | register char  *av[];
244          case 't':                       /* type */
245                  if (!av[0][3] || av[0][3]==' ')
246                          return(-1);
247 <                check(4,0);
247 >                check(4,"");
248                  v->type = av[0][3];
249                  return(0);
250          case 'p':                       /* point */
251 <                check(3,3);
251 >                check(3,"fff");
252                  v->vp[0] = atof(av[1]);
253                  v->vp[1] = atof(av[2]);
254                  v->vp[2] = atof(av[3]);
255                  return(3);
256          case 'd':                       /* direction */
257 <                check(3,3);
257 >                check(3,"fff");
258                  v->vdir[0] = atof(av[1]);
259                  v->vdir[1] = atof(av[2]);
260                  v->vdir[2] = atof(av[3]);
261                  return(3);
262          case 'u':                       /* up */
263 <                check(3,3);
263 >                check(3,"fff");
264                  v->vup[0] = atof(av[1]);
265                  v->vup[1] = atof(av[2]);
266                  v->vup[2] = atof(av[3]);
267                  return(3);
268          case 'h':                       /* horizontal size */
269 <                check(3,1);
269 >                check(3,"f");
270                  v->horiz = atof(av[1]);
271                  return(1);
272          case 'v':                       /* vertical size */
273 <                check(3,1);
273 >                check(3,"f");
274                  v->vert = atof(av[1]);
275                  return(1);
276          case 's':                       /* shift */
277 <                check(3,1);
277 >                check(3,"f");
278                  v->hoff = atof(av[1]);
279                  return(1);
280          case 'l':                       /* lift */
281 <                check(3,1);
281 >                check(3,"f");
282                  v->voff = atof(av[1]);
283                  return(1);
284          default:
# Line 335 | Line 333 | FILE  *fp;
333   }
334  
335  
338 static VIEW  *hview;                    /* view from header */
339 static int  gothview;                   /* success indicator */
336   static char  *altname[] = {NULL,"rpict","rview","pinterp",VIEWSTR,NULL};
337  
338 + struct myview {
339 +        VIEW    *hv;
340 +        int     ok;
341 + };
342  
343 +
344   static
345 < gethview(s)                             /* get view from header */
345 > gethview(s, v)                          /* get view from header */
346   char  *s;
347 + register struct myview  *v;
348   {
349          register char  **an;
350  
351          for (an = altname; *an != NULL; an++)
352                  if (!strncmp(*an, s, strlen(*an))) {
353 <                        if (sscanview(hview, s+strlen(*an)) > 0)
354 <                                gothview++;
353 >                        if (sscanview(v->hv, s+strlen(*an)) > 0)
354 >                                v->ok++;
355                          return;
356                  }
357   }
# Line 362 | Line 364 | VIEW  *vp;
364   int  *xp, *yp;
365   {
366          extern char  *progname;
367 +        struct myview   mvs;
368          FILE  *fp;
369  
370          if ((fp = fopen(fname, "r")) == NULL)
371                  return(-1);
372  
373          altname[0] = progname;
374 <        hview = vp;
375 <        gothview = 0;
374 >        mvs.hv = vp;
375 >        mvs.ok = 0;
376  
377 <        getheader(fp, gethview);
377 >        getheader(fp, gethview, &mvs);
378  
379          if (xp != NULL && yp != NULL
380                          && fgetresolu(xp, yp, fp) == -1)
381 <                gothview = 0;
381 >                mvs.ok = 0;
382  
383          fclose(fp);
384  
385 <        return(gothview);
385 >        return(mvs.ok);
386   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines