![]() |
|
|||
File indexing completed on 2025-02-21 09:30:10
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 /** @file vector3.h 0042 * @brief 3D vector structure, including operators when compiling in C++ 0043 */ 0044 #pragma once 0045 #ifndef AI_VECTOR3D_H_INC 0046 #define AI_VECTOR3D_H_INC 0047 0048 #ifdef __GNUC__ 0049 # pragma GCC system_header 0050 #endif 0051 0052 #ifdef __cplusplus 0053 # include <cmath> 0054 #else 0055 # include <math.h> 0056 #endif 0057 0058 #include <assimp/defs.h> 0059 0060 #ifdef __cplusplus 0061 0062 template<typename TReal> class aiMatrix3x3t; 0063 template<typename TReal> class aiMatrix4x4t; 0064 0065 // --------------------------------------------------------------------------- 0066 /// @brief Represents a three-dimensional vector. 0067 // --------------------------------------------------------------------------- 0068 template <typename TReal> 0069 class aiVector3t { 0070 public: 0071 /// @brief The default class constructor. 0072 aiVector3t() AI_NO_EXCEPT : x(), y(), z() {} 0073 0074 /// @brief The class constructor with the components. 0075 /// @param _x The x-component for the vector. 0076 /// @param _y The y-component for the vector. 0077 /// @param _z The z-component for the vector. 0078 aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {} 0079 0080 /// @brief The class constructor with a default value. 0081 /// @param _xyz The value for x, y and z. 0082 explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {} 0083 0084 /// @brief The copy constructor. 0085 /// @param o The instance to copy from. 0086 aiVector3t( const aiVector3t& o ) = default; 0087 0088 /// @brief combined operators 0089 /// @brief The copy constructor. 0090 const aiVector3t& operator += (const aiVector3t& o); 0091 0092 /// @brief The copy constructor. 0093 const aiVector3t& operator -= (const aiVector3t& o); 0094 0095 /// @brief The copy constructor. 0096 const aiVector3t& operator *= (TReal f); 0097 0098 /// @brief The copy constructor. 0099 const aiVector3t& operator /= (TReal f); 0100 0101 /// @brief Transform vector by matrix 0102 aiVector3t& operator *= (const aiMatrix3x3t<TReal>& mat); 0103 aiVector3t& operator *= (const aiMatrix4x4t<TReal>& mat); 0104 0105 /// @brief access a single element, const. 0106 TReal operator[](unsigned int i) const; 0107 0108 /// @brief access a single element, non-const. 0109 TReal& operator[](unsigned int i); 0110 0111 // comparison 0112 bool operator== (const aiVector3t& other) const; 0113 bool operator!= (const aiVector3t& other) const; 0114 bool operator < (const aiVector3t& other) const; 0115 0116 /// @brief 0117 bool Equal(const aiVector3t &other, TReal epsilon = ai_epsilon) const; 0118 0119 template <typename TOther> 0120 operator aiVector3t<TOther> () const; 0121 0122 /** @brief Set the components of a vector 0123 * @param pX X component 0124 * @param pY Y component 0125 * @param pZ Z component */ 0126 void Set( TReal pX, TReal pY, TReal pZ); 0127 0128 /** @brief Get the squared length of the vector 0129 * @return Square length */ 0130 TReal SquareLength() const; 0131 0132 /** @brief Get the length of the vector 0133 * @return length */ 0134 TReal Length() const; 0135 0136 0137 /** @brief Normalize the vector */ 0138 aiVector3t& Normalize(); 0139 0140 /** @brief Normalize the vector with extra check for zero vectors */ 0141 aiVector3t& NormalizeSafe(); 0142 0143 /** @brief Componentwise multiplication of two vectors 0144 * 0145 * Note that vec*vec yields the dot product. 0146 * @param o Second factor */ 0147 const aiVector3t SymMul(const aiVector3t& o); 0148 0149 TReal x, y, z; 0150 }; 0151 0152 0153 typedef aiVector3t<ai_real> aiVector3D; 0154 typedef aiVector3t<float> aiVector3f; 0155 typedef aiVector3t<double> aiVector3d; 0156 0157 #else 0158 0159 struct aiVector3D { 0160 ai_real x, y, z; 0161 }; 0162 0163 #endif // __cplusplus 0164 0165 #ifdef __cplusplus 0166 0167 #endif // __cplusplus 0168 0169 #endif // AI_VECTOR3D_H_INC
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |