vrshoot
diff libs/assimp/assimp/matrix3x3.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/assimp/matrix3x3.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,183 @@ 1.4 +/* 1.5 +--------------------------------------------------------------------------- 1.6 +Open Asset Import Library (assimp) 1.7 +--------------------------------------------------------------------------- 1.8 + 1.9 +Copyright (c) 2006-2012, assimp team 1.10 + 1.11 +All rights reserved. 1.12 + 1.13 +Redistribution and use of this software in source and binary forms, 1.14 +with or without modification, are permitted provided that the following 1.15 +conditions are met: 1.16 + 1.17 +* Redistributions of source code must retain the above 1.18 + copyright notice, this list of conditions and the 1.19 + following disclaimer. 1.20 + 1.21 +* Redistributions in binary form must reproduce the above 1.22 + copyright notice, this list of conditions and the 1.23 + following disclaimer in the documentation and/or other 1.24 + materials provided with the distribution. 1.25 + 1.26 +* Neither the name of the assimp team, nor the names of its 1.27 + contributors may be used to endorse or promote products 1.28 + derived from this software without specific prior 1.29 + written permission of the assimp team. 1.30 + 1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.42 +--------------------------------------------------------------------------- 1.43 +*/ 1.44 + 1.45 +/** @file matrix3x3.h 1.46 + * @brief Definition of a 3x3 matrix, including operators when compiling in C++ 1.47 + */ 1.48 +#ifndef AI_MATRIX3x3_H_INC 1.49 +#define AI_MATRIX3x3_H_INC 1.50 + 1.51 +#include "./Compiler/pushpack1.h" 1.52 + 1.53 +#ifdef __cplusplus 1.54 + 1.55 +template <typename T> class aiMatrix4x4t; 1.56 +template <typename T> class aiVector2t; 1.57 + 1.58 +// --------------------------------------------------------------------------- 1.59 +/** @brief Represents a row-major 3x3 matrix 1.60 + * 1.61 + * There's much confusion about matrix layouts (column vs. row order). 1.62 + * This is *always* a row-major matrix. Not even with the 1.63 + * #aiProcess_ConvertToLeftHanded flag, which absolutely does not affect 1.64 + * matrix order - it just affects the handedness of the coordinate system 1.65 + * defined thereby. 1.66 + */ 1.67 +template <typename TReal> 1.68 +class aiMatrix3x3t 1.69 +{ 1.70 +public: 1.71 + 1.72 + aiMatrix3x3t () : 1.73 + a1(static_cast<TReal>(1.0f)), a2(), a3(), 1.74 + b1(), b2(static_cast<TReal>(1.0f)), b3(), 1.75 + c1(), c2(), c3(static_cast<TReal>(1.0f)) {} 1.76 + 1.77 + aiMatrix3x3t ( TReal _a1, TReal _a2, TReal _a3, 1.78 + TReal _b1, TReal _b2, TReal _b3, 1.79 + TReal _c1, TReal _c2, TReal _c3) : 1.80 + a1(_a1), a2(_a2), a3(_a3), 1.81 + b1(_b1), b2(_b2), b3(_b3), 1.82 + c1(_c1), c2(_c2), c3(_c3) 1.83 + {} 1.84 + 1.85 +public: 1.86 + 1.87 + // matrix multiplication. 1.88 + aiMatrix3x3t& operator *= (const aiMatrix3x3t& m); 1.89 + aiMatrix3x3t operator * (const aiMatrix3x3t& m) const; 1.90 + 1.91 + // array access operators 1.92 + TReal* operator[] (unsigned int p_iIndex); 1.93 + const TReal* operator[] (unsigned int p_iIndex) const; 1.94 + 1.95 + // comparison operators 1.96 + bool operator== (const aiMatrix4x4t<TReal> m) const; 1.97 + bool operator!= (const aiMatrix4x4t<TReal> m) const; 1.98 + 1.99 + template <typename TOther> 1.100 + operator aiMatrix3x3t<TOther> () const; 1.101 + 1.102 +public: 1.103 + 1.104 + // ------------------------------------------------------------------- 1.105 + /** @brief Construction from a 4x4 matrix. The remaining parts 1.106 + * of the matrix are ignored. 1.107 + */ 1.108 + explicit aiMatrix3x3t( const aiMatrix4x4t<TReal>& pMatrix); 1.109 + 1.110 + // ------------------------------------------------------------------- 1.111 + /** @brief Transpose the matrix 1.112 + */ 1.113 + aiMatrix3x3t& Transpose(); 1.114 + 1.115 + // ------------------------------------------------------------------- 1.116 + /** @brief Invert the matrix. 1.117 + * If the matrix is not invertible all elements are set to qnan. 1.118 + * Beware, use (f != f) to check whether a TReal f is qnan. 1.119 + */ 1.120 + aiMatrix3x3t& Inverse(); 1.121 + TReal Determinant() const; 1.122 + 1.123 +public: 1.124 + // ------------------------------------------------------------------- 1.125 + /** @brief Returns a rotation matrix for a rotation around z 1.126 + * @param a Rotation angle, in radians 1.127 + * @param out Receives the output matrix 1.128 + * @return Reference to the output matrix 1.129 + */ 1.130 + static aiMatrix3x3t& RotationZ(TReal a, aiMatrix3x3t& out); 1.131 + 1.132 + // ------------------------------------------------------------------- 1.133 + /** @brief Returns a rotation matrix for a rotation around 1.134 + * an arbitrary axis. 1.135 + * 1.136 + * @param a Rotation angle, in radians 1.137 + * @param axis Axis to rotate around 1.138 + * @param out To be filled 1.139 + */ 1.140 + static aiMatrix3x3t& Rotation( TReal a, 1.141 + const aiVector3t<TReal>& axis, aiMatrix3x3t& out); 1.142 + 1.143 + // ------------------------------------------------------------------- 1.144 + /** @brief Returns a translation matrix 1.145 + * @param v Translation vector 1.146 + * @param out Receives the output matrix 1.147 + * @return Reference to the output matrix 1.148 + */ 1.149 + static aiMatrix3x3t& Translation( const aiVector2t<TReal>& v, aiMatrix3x3t& out); 1.150 + 1.151 + // ------------------------------------------------------------------- 1.152 + /** @brief A function for creating a rotation matrix that rotates a 1.153 + * vector called "from" into another vector called "to". 1.154 + * Input : from[3], to[3] which both must be *normalized* non-zero vectors 1.155 + * Output: mtx[3][3] -- a 3x3 matrix in colum-major form 1.156 + * Authors: Tomas Möller, John Hughes 1.157 + * "Efficiently Building a Matrix to Rotate One Vector to Another" 1.158 + * Journal of Graphics Tools, 4(4):1-4, 1999 1.159 + */ 1.160 + static aiMatrix3x3t& FromToMatrix(const aiVector3t<TReal>& from, 1.161 + const aiVector3t<TReal>& to, aiMatrix3x3t& out); 1.162 + 1.163 +public: 1.164 + 1.165 + 1.166 + TReal a1, a2, a3; 1.167 + TReal b1, b2, b3; 1.168 + TReal c1, c2, c3; 1.169 +} PACK_STRUCT; 1.170 + 1.171 +typedef aiMatrix3x3t<float> aiMatrix3x3; 1.172 + 1.173 +#else 1.174 + 1.175 +struct aiMatrix3x3 { 1.176 + 1.177 + float a1, a2, a3; 1.178 + float b1, b2, b3; 1.179 + float c1, c2, c3; 1.180 +} PACK_STRUCT; 1.181 + 1.182 +#endif 1.183 + 1.184 +#include "./Compiler/poppack1.h" 1.185 + 1.186 +#endif // AI_MATRIX3x3_H_INC