ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/xf.c
(Generate patch)

Comparing ray/src/common/xf.c (file contents):
Revision 1.5 by greg, Fri Oct 6 09:39:42 1989 UTC vs.
Revision 1.6 by greg, Fri Oct 13 19:34:51 1989 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13  
14   #define  PI             3.14159265358979323846
15 + #define  d2r(a)         ((PI/180.)*(a))
16  
17 < #define  checkarg(a,n)  if (strcmp(av[i],a) || i+n >= ac) goto done
17 > #define  checkarg(a,n)  if (av[i][a] || i+n >= ac) goto done
18  
19  
20   int
# Line 41 | Line 42 | char  *av[];
42                  switch (av[i][1]) {
43          
44                  case 't':                       /* translate */
45 <                        checkarg("-t",3);
45 >                        checkarg(2,3);
46                          m4[3][0] = atof(av[++i]);
47                          m4[3][1] = atof(av[++i]);
48                          m4[3][2] = atof(av[++i]);
# Line 50 | Line 51 | char  *av[];
51                  case 'r':                       /* rotate */
52                          switch (av[i][2]) {
53                          case 'x':
54 <                                checkarg("-rx",1);
55 <                                theta = PI/180.0 * atof(av[++i]);
54 >                                checkarg(3,1);
55 >                                theta = d2r(atof(av[++i]));
56                                  m4[1][1] = m4[2][2] = cos(theta);
57                                  m4[2][1] = -(m4[1][2] = sin(theta));
58                                  break;
59                          case 'y':
60 <                                checkarg("-ry",1);
61 <                                theta = PI/180.0 * atof(av[++i]);
60 >                                checkarg(3,1);
61 >                                theta = d2r(atof(av[++i]));
62                                  m4[0][0] = m4[2][2] = cos(theta);
63                                  m4[0][2] = -(m4[2][0] = sin(theta));
64                                  break;
65                          case 'z':
66 <                                checkarg("-rz",1);
67 <                                theta = PI/180.0 * atof(av[++i]);
66 >                                checkarg(3,1);
67 >                                theta = d2r(atof(av[++i]));
68                                  m4[0][0] = m4[1][1] = cos(theta);
69                                  m4[1][0] = -(m4[0][1] = sin(theta));
70                                  break;
# Line 73 | Line 74 | char  *av[];
74                          break;
75  
76                  case 's':                       /* scale */
77 <                        checkarg("-s",1);
77 >                        checkarg(2,1);
78                          xfsca *=
79                          m4[0][0] =
80                          m4[1][1] =
# Line 83 | Line 84 | char  *av[];
84                  case 'm':                       /* mirror */
85                          switch (av[i][2]) {
86                          case 'x':
87 <                                checkarg("-mx",0);
87 >                                checkarg(3,0);
88                                  xfsca *=
89                                  m4[0][0] = -1.0;
90                                  break;
91                          case 'y':
92 <                                checkarg("-my",0);
92 >                                checkarg(3,0);
93                                  xfsca *=
94                                  m4[1][1] = -1.0;
95                                  break;
96                          case 'z':
97 <                                checkarg("-mz",0);
97 >                                checkarg(3,0);
98                                  xfsca *=
99                                  m4[2][2] = -1.0;
100                                  break;
# Line 103 | Line 104 | char  *av[];
104                          break;
105  
106                  case 'i':                       /* iterate */
107 <                        checkarg("-i",1);
107 >                        checkarg(2,1);
108                          icnt = atoi(av[++i]);
109                          while (icnt-- > 0) {
110                                  multmat4(retmat, retmat, xfmat);
# Line 152 | Line 153 | char  *av[];
153                  switch (av[i][1]) {
154          
155                  case 't':                       /* translate */
156 <                        checkarg("-t",3);
156 >                        checkarg(2,3);
157                          m4[3][0] = -atof(av[++i]);
158                          m4[3][1] = -atof(av[++i]);
159                          m4[3][2] = -atof(av[++i]);
# Line 161 | Line 162 | char  *av[];
162                  case 'r':                       /* rotate */
163                          switch (av[i][2]) {
164                          case 'x':
165 <                                checkarg("-rx",1);
166 <                                theta = -PI/180.0 * atof(av[++i]);
165 >                                checkarg(3,1);
166 >                                theta = -d2r(atof(av[++i]));
167                                  m4[1][1] = m4[2][2] = cos(theta);
168                                  m4[2][1] = -(m4[1][2] = sin(theta));
169                                  break;
170                          case 'y':
171 <                                checkarg("-ry",1);
172 <                                theta = -PI/180.0 * atof(av[++i]);
171 >                                checkarg(3,1);
172 >                                theta = -d2r(atof(av[++i]));
173                                  m4[0][0] = m4[2][2] = cos(theta);
174                                  m4[0][2] = -(m4[2][0] = sin(theta));
175                                  break;
176                          case 'z':
177 <                                checkarg("-rz",1);
178 <                                theta = -PI/180.0 * atof(av[++i]);
177 >                                checkarg(3,1);
178 >                                theta = -d2r(atof(av[++i]));
179                                  m4[0][0] = m4[1][1] = cos(theta);
180                                  m4[1][0] = -(m4[0][1] = sin(theta));
181                                  break;
# Line 184 | Line 185 | char  *av[];
185                          break;
186  
187                  case 's':                       /* scale */
188 <                        checkarg("-s",1);
188 >                        checkarg(2,1);
189                          xfsca *=
190                          m4[0][0] =
191                          m4[1][1] =
# Line 194 | Line 195 | char  *av[];
195                  case 'm':                       /* mirror */
196                          switch (av[i][2]) {
197                          case 'x':
198 <                                checkarg("-mx",0);
198 >                                checkarg(3,0);
199                                  xfsca *=
200                                  m4[0][0] = -1.0;
201                                  break;
202                          case 'y':
203 <                                checkarg("-my",0);
203 >                                checkarg(3,0);
204                                  xfsca *=
205                                  m4[1][1] = -1.0;
206                                  break;
207                          case 'z':
208 <                                checkarg("-mz",0);
208 >                                checkarg(3,0);
209                                  xfsca *=
210                                  m4[2][2] = -1.0;
211                                  break;
# Line 214 | Line 215 | char  *av[];
215                          break;
216  
217                  case 'i':                       /* iterate */
218 <                        checkarg("-i",1);
218 >                        checkarg(2,1);
219                          icnt = atoi(av[++i]);
220                          while (icnt-- > 0) {
221                                  multmat4(retmat, xfmat, retmat);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines