Path Tracer
matrix4x4.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 
9 
10 All rights reserved.
11 
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
15 
16 * Redistributions of source code must retain the above
17  copyright notice, this list of conditions and the
18  following disclaimer.
19 
20 * Redistributions in binary form must reproduce the above
21  copyright notice, this list of conditions and the
22  following disclaimer in the documentation and/or other
23  materials provided with the distribution.
24 
25 * Neither the name of the assimp team, nor the names of its
26  contributors may be used to endorse or promote products
27  derived from this software without specific prior
28  written permission of the assimp team.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
46 #pragma once
47 #ifndef AI_MATRIX4X4_H_INC
48 #define AI_MATRIX4X4_H_INC
49 
50 #ifdef __GNUC__
51 # pragma GCC system_header
52 #endif
53 
54 #include <assimp/vector3.h>
55 #include <assimp/defs.h>
56 
57 #ifdef __cplusplus
58 
59 template<typename TReal> class aiMatrix3x3t;
60 template<typename TReal> class aiQuaterniont;
61 
62 // ---------------------------------------------------------------------------
72 template<typename TReal>
73 class aiMatrix4x4t {
74 public:
75 
77  aiMatrix4x4t() AI_NO_EXCEPT;
78 
80  aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
81  TReal _b1, TReal _b2, TReal _b3, TReal _b4,
82  TReal _c1, TReal _c2, TReal _c3, TReal _c4,
83  TReal _d1, TReal _d2, TReal _d3, TReal _d4);
84 
85 
87  explicit aiMatrix4x4t( const aiMatrix3x3t<TReal>& m);
88 
94  aiMatrix4x4t(const aiVector3t<TReal>& scaling, const aiQuaterniont<TReal>& rotation,
95  const aiVector3t<TReal>& position);
96 
97  // array access operators
102  TReal* operator[] (unsigned int p_iIndex);
103 
107  const TReal* operator[] (unsigned int p_iIndex) const;
108 
109  // comparison operators
110  bool operator== (const aiMatrix4x4t& m) const;
111  bool operator!= (const aiMatrix4x4t& m) const;
112 
113  bool Equal(const aiMatrix4x4t& m, TReal epsilon = 1e-6) const;
114 
115  // matrix multiplication.
116  aiMatrix4x4t& operator *= (const aiMatrix4x4t& m);
117  aiMatrix4x4t operator * (const aiMatrix4x4t& m) const;
118  aiMatrix4x4t operator * (const TReal& aFloat) const;
119  aiMatrix4x4t operator + (const aiMatrix4x4t& aMatrix) const;
120 
121  template <typename TOther>
122  operator aiMatrix4x4t<TOther> () const;
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  // -------------------------------------------------------------------
190  aiMatrix4x4t& FromEulerAnglesXYZ(TReal x, TReal y, TReal z);
191  aiMatrix4x4t& FromEulerAnglesXYZ(const aiVector3t<TReal>& blubb);
192 
193  // -------------------------------------------------------------------
199  static aiMatrix4x4t& RotationX(TReal a, aiMatrix4x4t& out);
200 
201  // -------------------------------------------------------------------
207  static aiMatrix4x4t& RotationY(TReal a, aiMatrix4x4t& out);
208 
209  // -------------------------------------------------------------------
215  static aiMatrix4x4t& RotationZ(TReal a, aiMatrix4x4t& out);
216 
217  // -------------------------------------------------------------------
224  static aiMatrix4x4t& Rotation(TReal a, const aiVector3t<TReal>& axis,
225  aiMatrix4x4t& out);
226 
227  // -------------------------------------------------------------------
233  static aiMatrix4x4t& Translation( const aiVector3t<TReal>& v,
234  aiMatrix4x4t& out);
235 
236  // -------------------------------------------------------------------
242  static aiMatrix4x4t& Scaling( const aiVector3t<TReal>& v, aiMatrix4x4t& out);
243 
244  // -------------------------------------------------------------------
253  static aiMatrix4x4t& FromToMatrix(const aiVector3t<TReal>& from,
254  const aiVector3t<TReal>& to, aiMatrix4x4t& out);
255 
256  TReal a1, a2, a3, a4;
257  TReal b1, b2, b3, b4;
258  TReal c1, c2, c3, c4;
259  TReal d1, d2, d3, d4;
260 };
261 
262 typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
263 
264 #else
265 
266 struct aiMatrix4x4 {
267  ai_real a1, a2, a3, a4;
268  ai_real b1, b2, b3, b4;
269  ai_real c1, c2, c3, c4;
270  ai_real d1, d2, d3, d4;
271 };
272 
273 
274 #endif // __cplusplus
275 
276 #endif // AI_MATRIX4X4_H_INC
matrix3x3.h
Definition of a 3x3 matrix, including operators when compiling in C++.
aiVector3D
Definition: vector3.h:136
matrix4x4.h
4x4 matrix structure, including operators when compiling in C++
vector3.h
3D vector structure, including operators when compiling in C++
defs.h
Assimp build configuration setup. See the notes in the comment blocks to find out how to customize yo...
aiMatrix4x4
Definition: matrix4x4.h:266