| 1 |
/************************************************************************ |
| 2 |
* |
| 3 |
* Generate a set of quaternions on stdout. |
| 4 |
* |
| 5 |
************************************************************************/ |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include <Inventor/SoDB.h> |
| 10 |
#include <Inventor/SbLinear.h> |
| 11 |
|
| 12 |
float |
| 13 |
rndf(void) |
| 14 |
{ |
| 15 |
return (float(rand()) / float(RAND_MAX) - 0.5f) * 4.0f; |
| 16 |
} |
| 17 |
|
| 18 |
int |
| 19 |
main(int argc, char ** argv) |
| 20 |
{ |
| 21 |
if (argc != 2) { |
| 22 |
(void)fprintf(stderr, |
| 23 |
"\n\n\tUsage: %s NUM\n\n" |
| 24 |
"\tNUM = number of quaternions to output.\n\n", |
| 25 |
argv[0]); |
| 26 |
exit(1); |
| 27 |
} |
| 28 |
|
| 29 |
SoDB::init(); |
| 30 |
|
| 31 |
srand(19720408); |
| 32 |
int num = atoi(argv[1]); |
| 33 |
for (int i=0; i < num; i++) { |
| 34 |
SbRotation q(rndf(), rndf(), rndf(), rndf()); |
| 35 |
float x, y, z, w; |
| 36 |
q.getValue(x, y, z, w); |
| 37 |
(void)fprintf(stdout, "%.3f %.3f %.3f %.3f\n", x, y, z, w); |
| 38 |
} |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |