| 14 |
|
|
| 15 |
|
#include "platform.h" |
| 16 |
|
#include "rtio.h" |
| 17 |
< |
#include "rtprocess.h" |
| 17 |
> |
#include "paths.h" |
| 18 |
|
#include "fvect.h" |
| 19 |
|
|
| 20 |
|
#ifdef M_PI |
| 23 |
|
#define PI 3.14159265358979323846 |
| 24 |
|
#endif |
| 25 |
|
|
| 26 |
– |
#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) |
| 27 |
– |
|
| 26 |
|
#define MAXVERT 6 /* maximum number of vertices for markers */ |
| 27 |
|
#define MAXMARK 128 /* maximum number of markers */ |
| 28 |
|
|
| 200 |
|
int i, n; |
| 201 |
|
register int j; |
| 202 |
|
|
| 203 |
< |
if (fscanf(fin, "%s %s %s", buf, typ, nam) != 3) |
| 203 |
> |
if (fgetword(buf, sizeof(buf), fin) == NULL || |
| 204 |
> |
fgetword(typ, sizeof(typ), fin) == NULL || |
| 205 |
> |
fgetword(nam, sizeof(nam), fin) == NULL) |
| 206 |
|
goto readerr; |
| 207 |
|
if (!strcmp(typ, "polygon")) |
| 208 |
|
for (j = 0; j < nmarkers; j++) |
| 210 |
|
replace(fname, &marker[j], nam, fin); |
| 211 |
|
return; |
| 212 |
|
} |
| 213 |
< |
printf("\n%s %s %s\n", buf, typ, nam); |
| 213 |
> |
putchar('\n'); fputword(buf, stdout); |
| 214 |
> |
printf(" %s ", typ); |
| 215 |
> |
fputword(nam, stdout); putchar('\n'); |
| 216 |
|
if (!strcmp(typ, "alias")) { /* alias special case */ |
| 217 |
< |
if (fscanf(fin, "%s", buf) != 1) |
| 217 |
> |
if (fgetword(buf, sizeof(buf), fin) == NULL) |
| 218 |
|
goto readerr; |
| 219 |
< |
printf("\t%s\n", buf); |
| 219 |
> |
putchar('\t'); fputword(buf, stdout); putchar('\n'); |
| 220 |
|
return; |
| 221 |
|
} |
| 222 |
|
for (i = 0; i < 3; i++) { /* pass along arguments */ |
| 389 |
|
int n; |
| 390 |
|
double theta; |
| 391 |
|
|
| 392 |
+ |
if (yp[2]*yp[2] + zp[2]*zp[2] < 2.*FTINY*FTINY) { |
| 393 |
+ |
/* Special case for X' along Z-axis */ |
| 394 |
+ |
theta = -atan2(yp[0], yp[1]); |
| 395 |
+ |
sprintf(xf, " -ry %f -rz %f", |
| 396 |
+ |
xp[2] < 0.0 ? 90.0 : -90.0, |
| 397 |
+ |
theta*(180./PI)); |
| 398 |
+ |
return(4); |
| 399 |
+ |
} |
| 400 |
|
n = 0; |
| 401 |
|
theta = atan2(yp[2], zp[2]); |
| 402 |
< |
if (!FEQ(theta,0.0)) { |
| 402 |
> |
if (!FABSEQ(theta,0.0)) { |
| 403 |
|
sprintf(xf, " -rx %f", theta*(180./PI)); |
| 404 |
|
while (*xf) ++xf; |
| 405 |
|
n += 2; |
| 406 |
|
} |
| 407 |
< |
theta = asin(-xp[2]); |
| 408 |
< |
if (!FEQ(theta,0.0)) { |
| 407 |
> |
theta = Asin(-xp[2]); |
| 408 |
> |
if (!FABSEQ(theta,0.0)) { |
| 409 |
|
sprintf(xf, " -ry %f", theta*(180./PI)); |
| 410 |
|
while (*xf) ++xf; |
| 411 |
|
n += 2; |
| 412 |
|
} |
| 413 |
|
theta = atan2(xp[1], xp[0]); |
| 414 |
< |
if (!FEQ(theta,0.0)) { |
| 414 |
> |
if (!FABSEQ(theta,0.0)) { |
| 415 |
|
sprintf(xf, " -rz %f", theta*(180./PI)); |
| 416 |
|
/* while (*xf) ++xf; */ |
| 417 |
|
n += 2; |