File: getTransform.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 (58 lines) | stat: -rw-r--r-- 1,684 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/************************************************************************
 *
 * void SbMatrix::getTransform(SbVec3f &, SbRotation &, SbVec3f &,
 *                             SbRotation &) const
 *
 ************************************************************************/

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


int
main(int argc, char ** argv)
{
  SoDB::init();

  // FIXME: istty(stdin). 20010114 mortene.

  int valsread;
  do {
    SbMat m;
    valsread = fscanf(stdin,
                      "%f %f %f %f "
                      "%f %f %f %f "
                      "%f %f %f %f "
                      "%f %f %f %f\n",
                      &m[0][0], &m[0][1], &m[0][2], &m[0][3],
                      &m[1][0], &m[1][1], &m[1][2], &m[1][3],
                      &m[2][0], &m[2][1], &m[2][2], &m[2][3],
                      &m[3][0], &m[3][1], &m[3][2], &m[3][3]);

    if (valsread == 16) {
      SbMatrix matrix(m);
      SbVec3f trans;
      SbRotation rot;
      SbVec3f scale;
      SbRotation so;
      matrix.getTransform(trans, rot, scale, so);

      (void)fprintf(stdout, "%.3f %.3f %.3f\n", trans[0], trans[1], trans[2]);
      const float * a = rot.getValue();
      (void)fprintf(stdout, "%.3f %.3f %.3f %3f\n", a[0], a[1], a[2], a[3]);
      (void)fprintf(stdout, "%.3f %.3f %.3f\n", scale[0], scale[1], scale[2]);
      a = so.getValue();
      (void)fprintf(stdout, "%.3f %.3f %.3f %3f\n", a[0], a[1], a[2], a[3]);
      (void)fprintf(stdout, "\n");
      
    }
  } while (valsread == 16);

  if (valsread != EOF) {
    (void)fflush(stdout);
    (void)fprintf(stderr, "Input data format error!\n");
  }

  return 0;
}