File: multLeft.cpp

package info (click to toggle)
coin3 4.0.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 52,388 kB
  • sloc: cpp: 254,256; 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 (52 lines) | stat: -rw-r--r-- 1,357 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
/************************************************************************
 *
 * SbMatrix::multLeft(SbMatrix)
 *
 ************************************************************************/

#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;
  SbMatrix rightmatrix = SbMatrix::identity();
  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 leftmatrix(m);
      rightmatrix.multLeft(leftmatrix);
      for (int i=0; i < 4; i++) {
        for (int j=0; j < 4; j++) {
          (void)fprintf(stdout, "%10.3f ", rightmatrix[i][j]);
        }
        (void)fprintf(stdout, "\n");
      }
      (void)fprintf(stdout, "\n");
    }
  } while (valsread == 16);

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

  return 0;
}