10 |
|
* 10/17/85 |
11 |
|
*/ |
12 |
|
|
13 |
+ |
#include <ctype.h> |
14 |
+ |
|
15 |
|
#include "standard.h" |
16 |
|
|
17 |
|
#include "view.h" |
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 |
|
{ |
79 |
|
v->vvinc[1] *= dt; |
80 |
|
v->vvinc[2] *= dt; |
81 |
|
|
82 |
+ |
v->vhn2 = DOT(v->vhinc,v->vhinc); |
83 |
+ |
v->vvn2 = DOT(v->vvinc,v->vvinc); |
84 |
+ |
|
85 |
|
return(NULL); |
86 |
|
} |
87 |
|
|
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->vhn2 + 0.5*v->hresolu; |
140 |
+ |
*yp = DOT(disp,v->vvinc)/v->vvn2 + 0.5*v->vresolu; |
141 |
+ |
} |
142 |
+ |
|
143 |
+ |
|
144 |
|
sscanview(vp, s) /* get view parameters */ |
145 |
|
register VIEW *vp; |
146 |
|
register char *s; |
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 |