1 |
– |
/* Copyright (c) 1990 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* xf.c - routines to convert transform arguments into 4X4 matrix. |
6 |
|
* |
7 |
< |
* 1/28/86 |
7 |
> |
* External symbols declared in rtmath.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include "standard.h" |
10 |
> |
#include <stdlib.h> |
11 |
> |
#include "rtmath.h" |
12 |
> |
#include "rtio.h" |
13 |
|
|
14 |
|
#define d2r(a) ((PI/180.)*(a)) |
15 |
|
|
17 |
|
|
18 |
|
|
19 |
|
int |
20 |
< |
xf(ret, ac, av) /* get transform specification */ |
22 |
< |
register XF *ret; |
23 |
< |
int ac; |
24 |
< |
char *av[]; |
20 |
> |
isxfopt(char *p) /* check whether option begins transform */ |
21 |
|
{ |
22 |
< |
double atof(), sin(), cos(); |
22 |
> |
if (*p++ != '-') |
23 |
> |
return(0); |
24 |
> |
|
25 |
> |
if ((p[0] == 't') | (p[0] == 's') | (p[0] == 'i') && |
26 |
> |
!p[1]) |
27 |
> |
return(1); |
28 |
> |
|
29 |
> |
if ((p[0] == 'r') | (p[0] == 'm') && |
30 |
> |
('x' <= p[1]) & (p[1] <= 'z') && |
31 |
> |
!p[2]) |
32 |
> |
return(1); |
33 |
> |
|
34 |
> |
return(0); |
35 |
> |
} |
36 |
> |
|
37 |
> |
|
38 |
> |
int |
39 |
> |
xf(XF *ret, int ac, char *av[]) /* get transform specification */ |
40 |
> |
{ |
41 |
|
MAT4 xfmat, m4; |
42 |
|
double xfsca, dtmp; |
43 |
|
int i, icnt; |
83 |
|
m4[1][0] = -(m4[0][1] = sin(dtmp)); |
84 |
|
break; |
85 |
|
default: |
86 |
< |
return(i); |
86 |
> |
goto done; |
87 |
|
} |
88 |
|
break; |
89 |
|
|
116 |
|
m4[2][2] = -1.0; |
117 |
|
break; |
118 |
|
default: |
119 |
< |
return(i); |
119 |
> |
goto done; |
120 |
|
} |
121 |
|
break; |
122 |
|
|
132 |
|
continue; |
133 |
|
|
134 |
|
default: |
135 |
< |
return(i); |
135 |
> |
goto done; |
136 |
|
|
137 |
|
} |
138 |
|
multmat4(xfmat, xfmat, m4); |
147 |
|
|
148 |
|
|
149 |
|
int |
150 |
< |
invxf(ret, ac, av) /* invert transform specification */ |
137 |
< |
register XF *ret; |
138 |
< |
int ac; |
139 |
< |
char *av[]; |
150 |
> |
invxf(XF *ret, int ac, char *av[]) /* invert transform specification */ |
151 |
|
{ |
141 |
– |
double atof(), sin(), cos(); |
152 |
|
MAT4 xfmat, m4; |
153 |
|
double xfsca, dtmp; |
154 |
|
int i, icnt; |
194 |
|
m4[1][0] = -(m4[0][1] = sin(dtmp)); |
195 |
|
break; |
196 |
|
default: |
197 |
< |
return(i); |
197 |
> |
goto done; |
198 |
|
} |
199 |
|
break; |
200 |
|
|
227 |
|
m4[2][2] = -1.0; |
228 |
|
break; |
229 |
|
default: |
230 |
< |
return(i); |
230 |
> |
goto done; |
231 |
|
} |
232 |
|
break; |
233 |
|
|
243 |
|
break; |
244 |
|
|
245 |
|
default: |
246 |
< |
return(i); |
246 |
> |
goto done; |
247 |
|
|
248 |
|
} |
249 |
|
multmat4(xfmat, m4, xfmat); /* left multiply */ |
258 |
|
|
259 |
|
|
260 |
|
int |
261 |
< |
fullxf(fx, ac, av) /* compute both forward and inverse */ |
252 |
< |
FULLXF *fx; |
253 |
< |
int ac; |
254 |
< |
char *av[]; |
261 |
> |
fullxf(FULLXF *fx, int ac, char *av[]) /* compute both forward and inverse */ |
262 |
|
{ |
263 |
|
xf(&fx->f, ac, av); |
264 |
|
return(invxf(&fx->b, ac, av)); |