File: generate.cpp

package info (click to toggle)
coin3 4.0.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 52,436 kB
  • sloc: cpp: 254,255; ansic: 23,018; makefile: 8,672; sh: 3,141; perl: 1,504; lex: 1,372; lisp: 1,247; pascal: 961; xml: 604; yacc: 388; sed: 68
file content (41 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/************************************************************************
 *
 * Generate a set of quaternions on stdout.
 *
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <Inventor/SoDB.h>
#include <Inventor/SbLinear.h>

float
rndf(void)
{
  return (float(rand()) / float(RAND_MAX) - 0.5f) * 4.0f;
}

int
main(int argc, char ** argv)
{
  if (argc != 2) {
    (void)fprintf(stderr,
                  "\n\n\tUsage: %s NUM\n\n"
                  "\tNUM = number of quaternions to output.\n\n",
                  argv[0]);
    exit(1);
  }

  SoDB::init();

  srand(19720408);
  int num = atoi(argv[1]);
  for (int i=0; i < num; i++) {
    SbRotation q(rndf(), rndf(), rndf(), rndf());
    float x, y, z, w;
    q.getValue(x, y, z, w);
    (void)fprintf(stdout, "%.3f %.3f %.3f %.3f\n", x, y, z, w);
  }

  return 0;
}