| 1 |
/************************************************************************ |
| 2 |
* |
| 3 |
* Generate a set of "valid" matrices (i.e. matrices put together from |
| 4 |
* a set of valid translations, scalevectors and rotations) on stdout. |
| 5 |
* |
| 6 |
************************************************************************/ |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <Inventor/SoDB.h> |
| 11 |
#include <Inventor/SbLinear.h> |
| 12 |
|
| 13 |
float |
| 14 |
rndf(void) |
| 15 |
{ |
| 16 |
return (float(rand()) / float(RAND_MAX) - 0.5f) * 4.0f; |
| 17 |
} |
| 18 |
|
| 19 |
int |
| 20 |
main(int argc, char ** argv) |
| 21 |
{ |
| 22 |
if (argc != 2) { |
| 23 |
(void)fprintf(stderr, |
| 24 |
"\n\n\tUsage: %s NUM\n\n" |
| 25 |
"\tNUM = number of matrices to output.\n\n", |
| 26 |
argv[0]); |
| 27 |
exit(1); |
| 28 |
} |
| 29 |
|
| 30 |
SoDB::init(); |
| 31 |
|
| 32 |
srand(19720408); |
| 33 |
int num = atoi(argv[1]); |
| 34 |
for (int i=0; i < num; i++) { |
| 35 |
SbMatrix m; |
| 36 |
m.setTransform(// translation |
| 37 |
SbVec3f(rndf(), rndf(), rndf()), |
| 38 |
// rotation |
| 39 |
SbRotation(SbVec3f(rndf(), rndf(), rndf()), rndf()), |
| 40 |
// scalevec |
| 41 |
SbVec3f(rndf(), rndf(), rndf()), |
| 42 |
// scaleorientation |
| 43 |
SbRotation(SbVec3f(rndf(), rndf(), rndf()), rndf()), |
| 44 |
// center |
| 45 |
SbVec3f(rndf(), rndf(), rndf())); |
| 46 |
|
| 47 |
(void)fprintf(stdout, |
| 48 |
"%.3f %.3f %.3f %.3f " |
| 49 |
"%.3f %.3f %.3f %.3f " |
| 50 |
"%.3f %.3f %.3f %.3f " |
| 51 |
"%.3f %.3f %.3f %.3f\n", |
| 52 |
m[0][0], m[0][1], m[0][2], m[0][3], |
| 53 |
m[1][0], m[1][1], m[1][2], m[1][3], |
| 54 |
m[2][0], m[2][1], m[2][2], m[2][3], |
| 55 |
m[3][0], m[3][1], m[3][2], m[3][3]); |
| 56 |
} |
| 57 |
|
| 58 |
return 0; |
| 59 |
} |