Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:09

0001 /*
0002 ---------------------------------------------------------------------------
0003 Open Asset Import Library (assimp)
0004 ---------------------------------------------------------------------------
0005 
0006 Copyright (c) 2006-2024, assimp team
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the following
0012 conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015   copyright notice, this list of conditions and the
0016   following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019   copyright notice, this list of conditions and the
0020   following disclaimer in the documentation and/or other
0021   materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024   contributors may be used to endorse or promote products
0025   derived from this software without specific prior
0026   written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 ---------------------------------------------------------------------------
0040 */
0041 
0042 /** @file matrix3x3.h
0043  *  @brief Definition of a 3x3 matrix, including operators when compiling in C++
0044  */
0045 #pragma once
0046 #ifndef AI_MATRIX3X3_H_INC
0047 #define AI_MATRIX3X3_H_INC
0048 
0049 #ifdef __GNUC__
0050 #   pragma GCC system_header
0051 #endif
0052 
0053 #include <assimp/defs.h>
0054 
0055 #ifdef __cplusplus
0056 
0057 template <typename T> class aiMatrix4x4t;
0058 template <typename T> class aiVector2t;
0059 template <typename T> class aiVector3t;
0060 
0061 // ---------------------------------------------------------------------------
0062 /** @brief Represents a row-major 3x3 matrix
0063  *
0064  *  There's much confusion about matrix layouts (column vs. row order).
0065  *  This is *always* a row-major matrix. Not even with the
0066  *  #aiProcess_ConvertToLeftHanded flag, which absolutely does not affect
0067  *  matrix order - it just affects the handedness of the coordinate system
0068  *  defined thereby.
0069  */
0070 template <typename TReal>
0071 class aiMatrix3x3t {
0072 public:
0073     aiMatrix3x3t() AI_NO_EXCEPT :
0074         a1(static_cast<TReal>(1.0f)), a2(), a3(),
0075         b1(), b2(static_cast<TReal>(1.0f)), b3(),
0076         c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
0077 
0078     aiMatrix3x3t (  TReal _a1, TReal _a2, TReal _a3,
0079                     TReal _b1, TReal _b2, TReal _b3,
0080                     TReal _c1, TReal _c2, TReal _c3) :
0081         a1(_a1), a2(_a2), a3(_a3),
0082         b1(_b1), b2(_b2), b3(_b3),
0083         c1(_c1), c2(_c2), c3(_c3)
0084     {}
0085 
0086     // matrix multiplication.
0087     aiMatrix3x3t& operator *= (const aiMatrix3x3t& m);
0088     aiMatrix3x3t  operator  * (const aiMatrix3x3t& m) const;
0089 
0090     // array access operators
0091     TReal* operator[]       (unsigned int p_iIndex);
0092     const TReal* operator[] (unsigned int p_iIndex) const;
0093 
0094     // comparison operators
0095     bool operator== (const aiMatrix3x3t<TReal>& m) const;
0096     bool operator!= (const aiMatrix3x3t<TReal>& m) const;
0097 
0098     bool Equal(const aiMatrix3x3t<TReal> &m, TReal epsilon = ai_epsilon) const;
0099 
0100     template <typename TOther>
0101     operator aiMatrix3x3t<TOther> () const;
0102 
0103     // -------------------------------------------------------------------
0104     /** @brief Construction from a 4x4 matrix. The remaining parts
0105      *  of the matrix are ignored.
0106      */
0107     explicit aiMatrix3x3t( const aiMatrix4x4t<TReal>& pMatrix);
0108 
0109     // -------------------------------------------------------------------
0110     /** @brief Transpose the matrix
0111      */
0112     aiMatrix3x3t& Transpose();
0113 
0114     // -------------------------------------------------------------------
0115     /** @brief Invert the matrix.
0116      *  If the matrix is not invertible all elements are set to qnan.
0117      *  Beware, use (f != f) to check whether a TReal f is qnan.
0118      */
0119     aiMatrix3x3t& Inverse();
0120     TReal Determinant() const;
0121 
0122     // -------------------------------------------------------------------
0123     /** @brief Returns a rotation matrix for a rotation around z
0124      *  @param a Rotation angle, in radians
0125      *  @param out Receives the output matrix
0126      *  @return Reference to the output matrix
0127      */
0128     static aiMatrix3x3t& RotationZ(TReal a, aiMatrix3x3t& out);
0129 
0130     // -------------------------------------------------------------------
0131     /** @brief Returns a rotation matrix for a rotation around
0132      *    an arbitrary axis.
0133      *
0134      *  @param a Rotation angle, in radians
0135      *  @param axis Axis to rotate around
0136      *  @param out To be filled
0137      */
0138     static aiMatrix3x3t& Rotation( TReal a, const aiVector3t<TReal>& axis, aiMatrix3x3t& out);
0139 
0140     // -------------------------------------------------------------------
0141     /** @brief Returns a translation matrix
0142      *  @param v Translation vector
0143      *  @param out Receives the output matrix
0144      *  @return Reference to the output matrix
0145      */
0146     static aiMatrix3x3t& Translation( const aiVector2t<TReal>& v, aiMatrix3x3t& out);
0147 
0148     // -------------------------------------------------------------------
0149     /** @brief A function for creating a rotation matrix that rotates a
0150      *  vector called "from" into another vector called "to".
0151      * Input : from[3], to[3] which both must be *normalized* non-zero vectors
0152      * Output: mtx[3][3] -- a 3x3 matrix in column-major form
0153      * Authors: Tomas Möller, John Hughes
0154      *          "Efficiently Building a Matrix to Rotate One Vector to Another"
0155      *          Journal of Graphics Tools, 4(4):1-4, 1999
0156      */
0157     static aiMatrix3x3t& FromToMatrix(const aiVector3t<TReal>& from,
0158         const aiVector3t<TReal>& to, aiMatrix3x3t& out);
0159 
0160 public:
0161     TReal a1, a2, a3;
0162     TReal b1, b2, b3;
0163     TReal c1, c2, c3;
0164 };
0165 
0166 typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
0167 
0168 #else
0169 
0170 struct aiMatrix3x3 {
0171     ai_real a1, a2, a3;
0172     ai_real b1, b2, b3;
0173     ai_real c1, c2, c3;
0174 };
0175 
0176 #endif // __cplusplus
0177 
0178 #endif // AI_MATRIX3X3_H_INC