Coin Logo http://www.coin3d.org/
http://www.kongsberg.com/kogt/

SbMatrix.h
1 #ifndef COIN_SBMATRIX_H
2 #define COIN_SBMATRIX_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <stdio.h>
37 #include <Inventor/SbBasic.h>
38 
39 class SbLine;
40 class SbRotation;
41 class SbVec3f;
42 class SbVec4f;
43 
44 typedef float SbMat[4][4];
45 
46 class COIN_DLL_API SbMatrix {
47 public:
48  SbMatrix(void);
49  SbMatrix(const float a11, const float a12, const float a13, const float a14,
50  const float a21, const float a22, const float a23, const float a24,
51  const float a31, const float a32, const float a33, const float a34,
52  const float a41, const float a42, const float a43, const float a44);
53  SbMatrix(const SbMat & matrix);
54  SbMatrix(const SbMat * matrix);
55  explicit SbMatrix(const class SbDPMatrix & matrix);
56  ~SbMatrix(void);
57 
58  void setValue(const SbMat & m);
59  void setValue(const class SbDPMatrix & m);
60  void setValue(const float * pMat);
61  const SbMat & getValue(void) const;
62 
63  void makeIdentity(void);
64  void setRotate(const SbRotation & q);
65  SbMatrix inverse(void) const;
66  float det3(int r1, int r2, int r3,
67  int c1, int c2, int c3) const;
68  float det3(void) const;
69  float det4(void) const;
70 
71  SbBool equals(const SbMatrix & m, float tolerance) const;
72 
73 
74  void getValue(SbMat & m) const;
75  static SbMatrix identity(void);
76  void setScale(const float s);
77  void setScale(const SbVec3f & s);
78  void setTranslate(const SbVec3f & t);
79  void setTransform(const SbVec3f & t, const SbRotation & r, const SbVec3f & s);
80  void setTransform(const SbVec3f & t, const SbRotation & r, const SbVec3f & s,
81  const SbRotation & so);
82  void setTransform(const SbVec3f & translation,
83  const SbRotation & rotation, const SbVec3f & scaleFactor,
84  const SbRotation & scaleOrientation, const SbVec3f & center);
85  void getTransform(SbVec3f & t, SbRotation & r,
86  SbVec3f & s, SbRotation & so) const;
87  void getTransform(SbVec3f & translation, SbRotation & rotation,
88  SbVec3f & scaleFactor, SbRotation & scaleOrientation,
89  const SbVec3f & center) const;
90  SbBool factor(SbMatrix & r, SbVec3f & s, SbMatrix & u, SbVec3f & t,
91  SbMatrix & proj);
92  SbBool LUDecomposition(int index[4], float & d);
93  void LUBackSubstitution(int index[4], float b[4]) const;
94  SbMatrix transpose(void) const;
95  SbMatrix & multRight(const SbMatrix & m);
96  SbMatrix & multLeft(const SbMatrix & m);
97  void multMatrixVec(const SbVec3f & src, SbVec3f & dst) const;
98  void multVecMatrix(const SbVec3f & src, SbVec3f & dst) const;
99  void multDirMatrix(const SbVec3f & src, SbVec3f & dst) const;
100  void multLineMatrix(const SbLine & src, SbLine & dst) const;
101  void multVecMatrix(const SbVec4f & src, SbVec4f & dst) const;
102 
103  void print(FILE * fp) const;
104 
105  operator float*(void);
106  operator SbMat&(void);
107 
108  float * operator [](int i);
109  const float * operator [](int i) const;
110 
111  SbMatrix & operator =(const SbMat & m);
112  SbMatrix & operator =(const SbMatrix & m);
113  SbMatrix & operator =(const SbRotation & q);
114  SbMatrix & operator *=(const SbMatrix & m);
115 
116  friend COIN_DLL_API SbMatrix operator *(const SbMatrix & m1, const SbMatrix & m2);
117  friend COIN_DLL_API int operator ==(const SbMatrix & m1, const SbMatrix & m2);
118  friend COIN_DLL_API int operator !=(const SbMatrix & m1, const SbMatrix & m2);
119 
120 private:
121  float matrix[4][4];
122 
123  void operator /=(const float v);
124  void operator *=(const float v);
125 };
126 
127 COIN_DLL_API SbMatrix operator *(const SbMatrix & m1, const SbMatrix & m2);
128 COIN_DLL_API int operator ==(const SbMatrix & m1, const SbMatrix & m2);
129 COIN_DLL_API int operator !=(const SbMatrix & m1, const SbMatrix & m2);
130 
131 #endif // !COIN_SBMATRIX_H
The SbVec4f class is a 4 dimensional vector with floating point coordinates.This vector class is used...
Definition: SbVec4f.h:49
The SbRotation class represents a rotation in 3D space.SbRotation is used extensively throughout the ...
Definition: SbRotation.h:44
The SbVec3f class is a 3 dimensional vector with floating point coordinates.This vector class is used...
Definition: SbVec3f.h:51
The SbLine class represents a line in 3D space.SbLine provides a way of specifying a directed line...
Definition: SbLine.h:41
The SbMatrix class is a 4x4 dimensional representation of a matrix.SbMatrix is used by many other cla...
Definition: SbMatrix.h:46
The SbDPMatrix class is a 4x4 dimensional representation of a double-precision matrix.This class is like the SbMatrix class, but uses double-precision floating point values for its elements. For more class documentation, see SbMatrix.
Definition: SbDPMatrix.h:47

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated for Coin by Doxygen