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.2 by greg, Fri Oct 20 16:53:03 1989 UTC vs.
Revision 1.3 by greg, Sun Dec 10 16:19:54 1989 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     10/17/85
11   */
12  
13 + #include  <ctype.h>
14 +
15   #include  "standard.h"
16  
17   #include  "view.h"
# Line 18 | Line 20 | VIEW  stdview = STDVIEW(512);          /* default view paramet
20  
21  
22   char *
23 + sskip(s)                /* skip a word */
24 + register char  *s;
25 + {
26 +        while (isspace(*s)) s++;
27 +        while (*s && !isspace(*s)) s++;
28 +        return(s);
29 + }
30 +
31 +
32 + char *
33   setview(v)              /* set vhinc and vvinc, return message on error */
34   register VIEW  *v;
35   {
# Line 67 | Line 79 | register VIEW  *v;
79          v->vvinc[1] *= dt;
80          v->vvinc[2] *= dt;
81  
82 +        v->vhs2 = 1.0/DOT(v->vhinc,v->vhinc);
83 +        v->vvs2 = 1.0/DOT(v->vvinc,v->vvinc);
84 +
85          return(NULL);
86   }
87  
# Line 76 | Line 91 | FVECT  orig, direc;
91   register VIEW  *v;
92   double  x, y;
93   {
79        register int  i;
80
94          x -= 0.5 * v->hresolu;
95          y -= 0.5 * v->vresolu;
96  
97          if (v->type == VT_PAR) {        /* parallel view */
98 <                for (i = 0; i < 3; i++)
99 <                        orig[i] = v->vp[i] + x*v->vhinc[i] + y*v->vvinc[i];
98 >                orig[0] = v->vp[0] + x*v->vhinc[0] + y*v->vvinc[0];
99 >                orig[1] = v->vp[1] + x*v->vhinc[1] + y*v->vvinc[1];
100 >                orig[2] = v->vp[2] + x*v->vhinc[2] + y*v->vvinc[2];
101                  VCOPY(direc, v->vdir);
102          } else {                        /* perspective view */
103                  VCOPY(orig, v->vp);
104 <                for (i = 0; i < 3; i++)
105 <                        direc[i] = v->vdir[i] + x*v->vhinc[i] + y*v->vvinc[i];
104 >                direc[0] = v->vdir[0] + x*v->vhinc[0] + y*v->vvinc[0];
105 >                direc[1] = v->vdir[1] + x*v->vhinc[1] + y*v->vvinc[1];
106 >                direc[2] = v->vdir[2] + x*v->vhinc[2] + y*v->vvinc[2];
107                  normalize(direc);
108          }
109   }
110  
111  
112 + pixelview(xp, yp, zp, v, p)             /* find image location for point */
113 + double  *xp, *yp, *zp;
114 + register VIEW  *v;
115 + FVECT  p;
116 + {
117 +        extern double  sqrt();
118 +        double  d;
119 +        FVECT  disp;
120 +        
121 +        disp[0] = p[0] - v->vp[0];
122 +        disp[1] = p[1] - v->vp[1];
123 +        disp[2] = p[2] - v->vp[2];
124 +
125 +        if (v->type == VT_PAR) {        /* parallel view */
126 +                if (zp != NULL)
127 +                        *zp = DOT(disp,v->vdir);
128 +        } else {                        /* perspective view */
129 +                d = 1.0/DOT(disp,v->vdir);
130 +                if (zp != NULL) {
131 +                        *zp = sqrt(DOT(disp,disp));
132 +                        if (d < 0.0)
133 +                                *zp = -*zp;
134 +                }
135 +                disp[0] *= d;
136 +                disp[1] *= d;
137 +                disp[2] *= d;
138 +        }
139 +        *xp = DOT(disp,v->vhinc)*v->vhs2 + 0.5*v->hresolu;
140 +        *yp = DOT(disp,v->vvinc)*v->vvs2 + 0.5*v->vresolu;
141 + }
142 +
143 +
144   sscanview(vp, s)                        /* get view parameters */
145   register VIEW  *vp;
146   register char  *s;
# Line 183 | Line 230 | FILE  *fp;
230  
231   static VIEW  *hview;                    /* view from header */
232   static int  gothview;                   /* success indicator */
233 < static char  *altname[] = {NULL,"rpict","rview",VIEWSTR,NULL};
233 > static char  *altname[] = {NULL,"rpict","rview","pinterp",VIEWSTR,NULL};
234  
235  
236   static

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines