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.16 by greg, Thu Nov 7 11:04:00 1991 UTC vs.
Revision 1.17 by greg, Mon Nov 11 14:00:14 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14  
15   #include  "view.h"
16  
17 + #include  "resolu.h"
18 +
19   VIEW  stdview = STDVIEW;                /* default view parameters */
20  
21  
# Line 162 | Line 164 | double  x, y;
164   }
165  
166  
167 < viewpixel(xp, yp, zp, v, p)             /* find image location for point */
168 < double  *xp, *yp, *zp;
167 > viewloc(ip, v, p)               /* find image location for point */
168 > FVECT  ip;
169   register VIEW  *v;
170   FVECT  p;
171   {
# Line 176 | Line 178 | FVECT  p;
178  
179          switch (v->type) {
180          case VT_PAR:                    /* parallel view */
181 <                if (zp != NULL)
180 <                        *zp = DOT(disp,v->vdir);
181 >                ip[2] = DOT(disp,v->vdir);
182                  break;
183          case VT_PER:                    /* perspective view */
184                  d = DOT(disp,v->vdir);
185 <                if (zp != NULL) {
186 <                        *zp = sqrt(DOT(disp,disp));
187 <                        if (d < 0.0)
187 <                                *zp = -*zp;
188 <                }
189 <                if (d < 0.0)            /* fold pyramid */
185 >                ip[2] = sqrt(DOT(disp,disp));
186 >                if (d < 0.0) {          /* fold pyramid */
187 >                        ip[2] = -ip[2];
188                          d = -d;
189 <                if (d > FTINY) {
189 >                } else if (d > FTINY) {
190                          d = 1.0/d;
191                          disp[0] *= d;
192                          disp[1] *= d;
# Line 197 | Line 195 | FVECT  p;
195                  break;
196          case VT_HEM:                    /* hemispherical fisheye */
197                  d = normalize(disp);
198 <                if (zp != NULL) {
199 <                        if (DOT(disp,v->vdir) < 0.0)
200 <                                *zp = -d;
201 <                        else
204 <                                *zp = d;
205 <                }
198 >                if (DOT(disp,v->vdir) < 0.0)
199 >                        ip[2] = -d;
200 >                else
201 >                        ip[2] = d;
202                  break;
203          case VT_ANG:                    /* angular fisheye */
204 <                d = normalize(disp);
205 <                if (zp != NULL)
206 <                        *zp = d;
211 <                *xp = 0.5 - v->hoff;
212 <                *yp = 0.5 - v->voff;
204 >                ip[0] = 0.5 - v->hoff;
205 >                ip[1] = 0.5 - v->voff;
206 >                ip[2] = normalize(disp);
207                  d = DOT(disp,v->vdir);
208                  if (d >= 1.0-FTINY)
209                          return;
210                  if (d <= -(1.0-FTINY)) {
211 <                        *xp += 180.0/v->horiz;
212 <                        *yp += 180.0/v->vert;
211 >                        ip[1] += 180.0/v->horiz;
212 >                        ip[2] += 180.0/v->vert;
213                          return;
214                  }
215                  d = acos(d)/PI / sqrt(1.0 - d*d);
216 <                *xp += DOT(disp,v->hvec)*d*180.0/v->horiz;
217 <                *yp += DOT(disp,v->vvec)*d*180.0/v->vert;
216 >                ip[0] += DOT(disp,v->hvec)*d*180.0/v->horiz;
217 >                ip[1] += DOT(disp,v->vvec)*d*180.0/v->vert;
218                  return;
219          }
220 <        *xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
221 <        *yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
220 >        ip[0] = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
221 >        ip[1] = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
222   }
223  
224  
225 + pix2loc(loc, rp, px, py)        /* compute image location from pixel pos. */
226 + FLOAT  loc[2];
227 + register RESOLU  *rp;
228 + int  px, py;
229 + {
230 +        register int  x, y;
231 +
232 +        if (rp->or & YMAJOR) {
233 +                x = px;
234 +                y = py;
235 +        } else {
236 +                x = py;
237 +                y = px;
238 +        }
239 +        if (rp->or & XDECR)
240 +                x = rp->xr-1 - x;
241 +        if (rp->or & YDECR)
242 +                y = rp->yr-1 - y;
243 +        loc[0] = (x+.5)/rp->xr;
244 +        loc[1] = (y+.5)/rp->yr;
245 + }
246 +
247 +
248 + loc2pix(pp, rp, lx, ly)         /* compute pixel pos. from image location */
249 + int  pp[2];
250 + register RESOLU  *rp;
251 + double  lx, ly;
252 + {
253 +        register int  x, y;
254 +
255 +        x = lx * rp->xr;
256 +        y = ly * rp->yr;
257 +        if (rp->or & XDECR)
258 +                x = rp->xr-1 - x;
259 +        if (rp->or & YDECR)
260 +                y = rp->yr-1 - y;
261 +        if (rp->or & YMAJOR) {
262 +                pp[0] = x;
263 +                pp[1] = y;
264 +        } else {
265 +                pp[0] = y;
266 +                pp[1] = x;
267 +        }
268 + }
269 +
270 +
271   int
272   getviewopt(v, ac, av)                   /* process view argument */
273   register VIEW  *v;
# Line 358 | Line 398 | register struct myview  *v;
398  
399  
400   int
401 < viewfile(fname, vp, xp, yp)             /* get view from file */
401 > viewfile(fname, vp, rp)                 /* get view from file */
402   char  *fname;
403   VIEW  *vp;
404 < int  *xp, *yp;
404 > RESOLU  *rp;
405   {
406          extern char  *progname;
407          struct myview   mvs;
# Line 376 | Line 416 | int  *xp, *yp;
416  
417          getheader(fp, gethview, &mvs);
418  
419 <        if (xp != NULL && yp != NULL
380 <                        && fgetresolu(xp, yp, fp) == -1)
419 >        if (rp != NULL && !fgetsresolu(rp, fp))
420                  mvs.ok = 0;
421  
422          fclose(fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines