GraphicsAPI_2020C
matrix4x4.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16  copyright notice, this list of conditions and the
17  following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20  copyright notice, this list of conditions and the
21  following disclaimer in the documentation and/or other
22  materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25  contributors may be used to endorse or promote products
26  derived from this software without specific prior
27  written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
45 #pragma once
46 #ifndef AI_MATRIX4X4_H_INC
47 #define AI_MATRIX4X4_H_INC
48 
49 #include "vector3.h"
50 #include "defs.h"
51 
52 #ifdef __cplusplus
53 
54 template<typename TReal> class aiMatrix3x3t;
55 template<typename TReal> class aiQuaterniont;
56 
57 // ---------------------------------------------------------------------------
67 template<typename TReal>
68 class aiMatrix4x4t
69 {
70 public:
71 
73  aiMatrix4x4t ();
74 
76  aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
77  TReal _b1, TReal _b2, TReal _b3, TReal _b4,
78  TReal _c1, TReal _c2, TReal _c3, TReal _c4,
79  TReal _d1, TReal _d2, TReal _d3, TReal _d4);
80 
81 
83  explicit aiMatrix4x4t( const aiMatrix3x3t<TReal>& m);
84 
90  aiMatrix4x4t(const aiVector3t<TReal>& scaling, const aiQuaterniont<TReal>& rotation,
91  const aiVector3t<TReal>& position);
92 
93 public:
94 
95  // array access operators
100  TReal* operator[] (unsigned int p_iIndex);
101 
105  const TReal* operator[] (unsigned int p_iIndex) const;
106 
107  // comparison operators
108  bool operator== (const aiMatrix4x4t& m) const;
109  bool operator!= (const aiMatrix4x4t& m) const;
110 
111  bool Equal(const aiMatrix4x4t& m, TReal epsilon = 1e-6) const;
112 
113  // matrix multiplication.
114  aiMatrix4x4t& operator *= (const aiMatrix4x4t& m);
115  aiMatrix4x4t operator * (const aiMatrix4x4t& m) const;
116  aiMatrix4x4t operator * (const TReal& aFloat) const;
117  aiMatrix4x4t operator + (const aiMatrix4x4t& aMatrix) const;
118 
119  template <typename TOther>
120  operator aiMatrix4x4t<TOther> () const;
121 
122 public:
123 
124  // -------------------------------------------------------------------
126  aiMatrix4x4t& Transpose();
127 
128  // -------------------------------------------------------------------
133  aiMatrix4x4t& Inverse();
134  TReal Determinant() const;
135 
136 
137  // -------------------------------------------------------------------
141  inline bool IsIdentity() const;
142 
143  // -------------------------------------------------------------------
150  void Decompose (aiVector3t<TReal>& scaling, aiQuaterniont<TReal>& rotation,
151  aiVector3t<TReal>& position) const;
152 
153  // -------------------------------------------------------------------
161  void Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotation, aiVector3t<TReal>& pPosition) const;
162 
163  // -------------------------------------------------------------------
172  void Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotationAxis, TReal& pRotationAngle, aiVector3t<TReal>& pPosition) const;
173 
174  // -------------------------------------------------------------------
181  void DecomposeNoScaling (aiQuaterniont<TReal>& rotation,
182  aiVector3t<TReal>& position) const;
183 
184 
185  // -------------------------------------------------------------------
191  aiMatrix4x4t& FromEulerAnglesXYZ(TReal x, TReal y, TReal z);
192  aiMatrix4x4t& FromEulerAnglesXYZ(const aiVector3t<TReal>& blubb);
193 
194 public:
195  // -------------------------------------------------------------------
201  static aiMatrix4x4t& RotationX(TReal a, aiMatrix4x4t& out);
202 
203  // -------------------------------------------------------------------
209  static aiMatrix4x4t& RotationY(TReal a, aiMatrix4x4t& out);
210 
211  // -------------------------------------------------------------------
217  static aiMatrix4x4t& RotationZ(TReal a, aiMatrix4x4t& out);
218 
219  // -------------------------------------------------------------------
226  static aiMatrix4x4t& Rotation(TReal a, const aiVector3t<TReal>& axis,
227  aiMatrix4x4t& out);
228 
229  // -------------------------------------------------------------------
235  static aiMatrix4x4t& Translation( const aiVector3t<TReal>& v,
236  aiMatrix4x4t& out);
237 
238  // -------------------------------------------------------------------
244  static aiMatrix4x4t& Scaling( const aiVector3t<TReal>& v, aiMatrix4x4t& out);
245 
246  // -------------------------------------------------------------------
255  static aiMatrix4x4t& FromToMatrix(const aiVector3t<TReal>& from,
256  const aiVector3t<TReal>& to, aiMatrix4x4t& out);
257 
258 public:
259  TReal a1, a2, a3, a4;
260  TReal b1, b2, b3, b4;
261  TReal c1, c2, c3, c4;
262  TReal d1, d2, d3, d4;
263 };
264 
265 typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
266 
267 #else
268 
269 struct aiMatrix4x4 {
270  ai_real a1, a2, a3, a4;
271  ai_real b1, b2, b3, b4;
272  ai_real c1, c2, c3, c4;
273  ai_real d1, d2, d3, d4;
274 };
275 
276 
277 #endif // __cplusplus
278 
279 #endif // AI_MATRIX4X4_H_INC
3D vector structure, including operators when compiling in C++
Definition: matrix4x4.h:269
Assimp build configuration setup.
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon()
Return the epsilon constant for floating point types.
Definition: scalar_constants.inl:6
GLM_FUNC_DECL qua< T, Q > rotation(vec< 3, T, Q > const &orig, vec< 3, T, Q > const &dest)
Compute the rotation between two vectors.
Definition: quaternion.inl:122
GLM_FUNC_DECL GLM_CONSTEXPR genType e()
Return e constant.
Definition: constants.inl:102
GLM_FUNC_DECL vec< 3, T, Q > axis(qua< T, Q > const &x)
Returns the q rotation axis.
Definition: quaternion_trigonometric.inl:17