1/*
2---------------------------------------------------------------------------
3Open Asset Import Library (assimp)
4---------------------------------------------------------------------------
5
6Copyright (c) 2006-2019, assimp team
7
8
9
10All rights reserved.
11
12Redistribution and use of this software in source and binary forms,
13with or without modification, are permitted provided that the following
14conditions 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
30THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41---------------------------------------------------------------------------
42*/
43
44/** @file matrix3x3.h
45 * @brief Definition of a 3x3 matrix, including operators when compiling in C++
46 */
47#pragma once
48#ifndef AI_MATRIX3X3_H_INC
49#define AI_MATRIX3X3_H_INC
50
51#include "defs.h"
52
53#ifdef __cplusplus
54
55template <typename T> class aiMatrix4x4t;
56template <typename T> class aiVector2t;
57
58// ---------------------------------------------------------------------------
59/** @brief Represents a row-major 3x3 matrix
60 *
61 * There's much confusion about matrix layouts (column vs. row order).
62 * This is *always* a row-major matrix. Not even with the
63 * #aiProcess_ConvertToLeftHanded flag, which absolutely does not affect
64 * matrix order - it just affects the handedness of the coordinate system
65 * defined thereby.
66 */
67template <typename TReal>
68class aiMatrix3x3t
69{
70public:
71
72 aiMatrix3x3t() AI_NO_EXCEPT :
73 a1(static_cast<TReal>(1.0f)), a2(), a3(),
74 b1(), b2(static_cast<TReal>(1.0f)), b3(),
75 c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
76
77 aiMatrix3x3t ( TReal _a1, TReal _a2, TReal _a3,
78 TReal _b1, TReal _b2, TReal _b3,
79 TReal _c1, TReal _c2, TReal _c3) :
80 a1(_a1), a2(_a2), a3(_a3),
81 b1(_b1), b2(_b2), b3(_b3),
82 c1(_c1), c2(_c2), c3(_c3)
83 {}
84
85public:
86
87 // matrix multiplication.
88 aiMatrix3x3t& operator *= (const aiMatrix3x3t& m);
89 aiMatrix3x3t operator * (const aiMatrix3x3t& m) const;
90
91 // array access operators
92 TReal* operator[] (unsigned int p_iIndex);
93 const TReal* operator[] (unsigned int p_iIndex) const;
94
95 // comparison operators
96 bool operator== (const aiMatrix4x4t<TReal>& m) const;
97 bool operator!= (const aiMatrix4x4t<TReal>& m) const;
98
99 bool Equal(const aiMatrix4x4t<TReal>& m, TReal epsilon = 1e-6) const;
100
101 template <typename TOther>
102 operator aiMatrix3x3t<TOther> () const;
103
104public:
105
106 // -------------------------------------------------------------------
107 /** @brief Construction from a 4x4 matrix. The remaining parts
108 * of the matrix are ignored.
109 */
110 explicit aiMatrix3x3t( const aiMatrix4x4t<TReal>& pMatrix);
111
112 // -------------------------------------------------------------------
113 /** @brief Transpose the matrix
114 */
115 aiMatrix3x3t& Transpose();
116
117 // -------------------------------------------------------------------
118 /** @brief Invert the matrix.
119 * If the matrix is not invertible all elements are set to qnan.
120 * Beware, use (f != f) to check whether a TReal f is qnan.
121 */
122 aiMatrix3x3t& Inverse();
123 TReal Determinant() const;
124
125public:
126 // -------------------------------------------------------------------
127 /** @brief Returns a rotation matrix for a rotation around z
128 * @param a Rotation angle, in radians
129 * @param out Receives the output matrix
130 * @return Reference to the output matrix
131 */
132 static aiMatrix3x3t& RotationZ(TReal a, aiMatrix3x3t& out);
133
134 // -------------------------------------------------------------------
135 /** @brief Returns a rotation matrix for a rotation around
136 * an arbitrary axis.
137 *
138 * @param a Rotation angle, in radians
139 * @param axis Axis to rotate around
140 * @param out To be filled
141 */
142 static aiMatrix3x3t& Rotation( TReal a,
143 const aiVector3t<TReal>& axis, aiMatrix3x3t& out);
144
145 // -------------------------------------------------------------------
146 /** @brief Returns a translation matrix
147 * @param v Translation vector
148 * @param out Receives the output matrix
149 * @return Reference to the output matrix
150 */
151 static aiMatrix3x3t& Translation( const aiVector2t<TReal>& v, aiMatrix3x3t& out);
152
153 // -------------------------------------------------------------------
154 /** @brief A function for creating a rotation matrix that rotates a
155 * vector called "from" into another vector called "to".
156 * Input : from[3], to[3] which both must be *normalized* non-zero vectors
157 * Output: mtx[3][3] -- a 3x3 matrix in column-major form
158 * Authors: Tomas Möller, John Hughes
159 * "Efficiently Building a Matrix to Rotate One Vector to Another"
160 * Journal of Graphics Tools, 4(4):1-4, 1999
161 */
162 static aiMatrix3x3t& FromToMatrix(const aiVector3t<TReal>& from,
163 const aiVector3t<TReal>& to, aiMatrix3x3t& out);
164
165public:
166 TReal a1, a2, a3;
167 TReal b1, b2, b3;
168 TReal c1, c2, c3;
169};
170
171typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
172
173#else
174
175struct aiMatrix3x3 {
176 ai_real a1, a2, a3;
177 ai_real b1, b2, b3;
178 ai_real c1, c2, c3;
179};
180
181#endif // __cplusplus
182
183#endif // AI_MATRIX3X3_H_INC
184

source code of qt3d/src/3rdparty/assimp/src/include/assimp/matrix3x3.h