BRE12
matrix4x4.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 */
44 #ifndef AI_MATRIX4X4_H_INC
45 #define AI_MATRIX4X4_H_INC
46 
47 #include "./Compiler/pushpack1.h"
48 
49 #ifdef __cplusplus
50 
51 template<typename TReal> class aiMatrix3x3t;
52 template<typename TReal> class aiQuaterniont;
53 
54 // ---------------------------------------------------------------------------
64 template<typename TReal>
65 class aiMatrix4x4t
66 {
67 public:
68 
70  aiMatrix4x4t ();
71 
73  aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
74  TReal _b1, TReal _b2, TReal _b3, TReal _b4,
75  TReal _c1, TReal _c2, TReal _c3, TReal _c4,
76  TReal _d1, TReal _d2, TReal _d3, TReal _d4);
77 
78 
80  explicit aiMatrix4x4t( const aiMatrix3x3t<TReal>& m);
81 
87  aiMatrix4x4t(const aiVector3t<TReal>& scaling, const aiQuaterniont<TReal>& rotation,
88  const aiVector3t<TReal>& position);
89 
90 public:
91 
92  // array access operators
93  TReal* operator[] (unsigned int p_iIndex);
94  const TReal* operator[] (unsigned int p_iIndex) const;
95 
96  // comparison operators
97  bool operator== (const aiMatrix4x4t& m) const;
98  bool operator!= (const aiMatrix4x4t& m) const;
99 
100  bool Equal(const aiMatrix4x4t& m, TReal epsilon = 1e-6) const;
101 
102  // matrix multiplication.
103  aiMatrix4x4t& operator *= (const aiMatrix4x4t& m);
104  aiMatrix4x4t operator * (const aiMatrix4x4t& m) const;
105 
106  template <typename TOther>
107  operator aiMatrix4x4t<TOther> () const;
108 
109 public:
110 
111  // -------------------------------------------------------------------
113  aiMatrix4x4t& Transpose();
114 
115  // -------------------------------------------------------------------
120  aiMatrix4x4t& Inverse();
121  TReal Determinant() const;
122 
123 
124  // -------------------------------------------------------------------
128  inline bool IsIdentity() const;
129 
130  // -------------------------------------------------------------------
137  void Decompose (aiVector3t<TReal>& scaling, aiQuaterniont<TReal>& rotation,
138  aiVector3t<TReal>& position) const;
139 
140  // -------------------------------------------------------------------
147  void DecomposeNoScaling (aiQuaterniont<TReal>& rotation,
148  aiVector3t<TReal>& position) const;
149 
150 
151  // -------------------------------------------------------------------
157  aiMatrix4x4t& FromEulerAnglesXYZ(TReal x, TReal y, TReal z);
158  aiMatrix4x4t& FromEulerAnglesXYZ(const aiVector3t<TReal>& blubb);
159 
160 public:
161  // -------------------------------------------------------------------
167  static aiMatrix4x4t& RotationX(TReal a, aiMatrix4x4t& out);
168 
169  // -------------------------------------------------------------------
175  static aiMatrix4x4t& RotationY(TReal a, aiMatrix4x4t& out);
176 
177  // -------------------------------------------------------------------
183  static aiMatrix4x4t& RotationZ(TReal a, aiMatrix4x4t& out);
184 
185  // -------------------------------------------------------------------
192  static aiMatrix4x4t& Rotation(TReal a, const aiVector3t<TReal>& axis,
193  aiMatrix4x4t& out);
194 
195  // -------------------------------------------------------------------
201  static aiMatrix4x4t& Translation( const aiVector3t<TReal>& v, aiMatrix4x4t& out);
202 
203  // -------------------------------------------------------------------
209  static aiMatrix4x4t& Scaling( const aiVector3t<TReal>& v, aiMatrix4x4t& out);
210 
211  // -------------------------------------------------------------------
220  static aiMatrix4x4t& FromToMatrix(const aiVector3t<TReal>& from,
221  const aiVector3t<TReal>& to, aiMatrix4x4t& out);
222 
223 public:
224 
225  TReal a1, a2, a3, a4;
226  TReal b1, b2, b3, b4;
227  TReal c1, c2, c3, c4;
228  TReal d1, d2, d3, d4;
229 
230 } PACK_STRUCT;
231 
232 typedef aiMatrix4x4t<float> aiMatrix4x4;
233 
234 #else
235 
236 struct aiMatrix4x4 {
237  float a1, a2, a3, a4;
238  float b1, b2, b3, b4;
239  float c1, c2, c3, c4;
240  float d1, d2, d3, d4;
241 };
242 
243 
244 #endif // __cplusplus
245 
246 #include "./Compiler/poppack1.h"
247 
248 #endif // AI_MATRIX4X4_H_INC
Definition: matrix4x4.h:236