BRE12
matrix3x3.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
45 #ifndef AI_MATRIX3x3_H_INC
46 #define AI_MATRIX3x3_H_INC
47 
48 #include "./Compiler/pushpack1.h"
49 
50 #ifdef __cplusplus
51 
52 template <typename T> class aiMatrix4x4t;
53 template <typename T> class aiVector2t;
54 
55 // ---------------------------------------------------------------------------
64 template <typename TReal>
65 class aiMatrix3x3t
66 {
67 public:
68 
69  aiMatrix3x3t () :
70  a1(static_cast<TReal>(1.0f)), a2(), a3(),
71  b1(), b2(static_cast<TReal>(1.0f)), b3(),
72  c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
73 
74  aiMatrix3x3t ( TReal _a1, TReal _a2, TReal _a3,
75  TReal _b1, TReal _b2, TReal _b3,
76  TReal _c1, TReal _c2, TReal _c3) :
77  a1(_a1), a2(_a2), a3(_a3),
78  b1(_b1), b2(_b2), b3(_b3),
79  c1(_c1), c2(_c2), c3(_c3)
80  {}
81 
82 public:
83 
84  // matrix multiplication.
85  aiMatrix3x3t& operator *= (const aiMatrix3x3t& m);
86  aiMatrix3x3t operator * (const aiMatrix3x3t& m) const;
87 
88  // array access operators
89  TReal* operator[] (unsigned int p_iIndex);
90  const TReal* operator[] (unsigned int p_iIndex) const;
91 
92  // comparison operators
93  bool operator== (const aiMatrix4x4t<TReal>& m) const;
94  bool operator!= (const aiMatrix4x4t<TReal>& m) const;
95 
96  bool Equal(const aiMatrix4x4t<TReal>& m, TReal epsilon = 1e-6) const;
97 
98  template <typename TOther>
99  operator aiMatrix3x3t<TOther> () const;
100 
101 public:
102 
103  // -------------------------------------------------------------------
107  explicit aiMatrix3x3t( const aiMatrix4x4t<TReal>& pMatrix);
108 
109  // -------------------------------------------------------------------
112  aiMatrix3x3t& Transpose();
113 
114  // -------------------------------------------------------------------
119  aiMatrix3x3t& Inverse();
120  TReal Determinant() const;
121 
122 public:
123  // -------------------------------------------------------------------
129  static aiMatrix3x3t& RotationZ(TReal a, aiMatrix3x3t& out);
130 
131  // -------------------------------------------------------------------
139  static aiMatrix3x3t& Rotation( TReal a,
140  const aiVector3t<TReal>& axis, aiMatrix3x3t& out);
141 
142  // -------------------------------------------------------------------
148  static aiMatrix3x3t& Translation( const aiVector2t<TReal>& v, aiMatrix3x3t& out);
149 
150  // -------------------------------------------------------------------
159  static aiMatrix3x3t& FromToMatrix(const aiVector3t<TReal>& from,
160  const aiVector3t<TReal>& to, aiMatrix3x3t& out);
161 
162 public:
163 
164 
165  TReal a1, a2, a3;
166  TReal b1, b2, b3;
167  TReal c1, c2, c3;
168 } PACK_STRUCT;
169 
170 typedef aiMatrix3x3t<float> aiMatrix3x3;
171 
172 #else
173 
174 struct aiMatrix3x3 {
175 
176  float a1, a2, a3;
177  float b1, b2, b3;
178  float c1, c2, c3;
179 } PACK_STRUCT;
180 
181 #endif
182 
183 #include "./Compiler/poppack1.h"
184 
185 #endif // AI_MATRIX3x3_H_INC
Definition: matrix3x3.h:174