GraphicsAPI_2020C
vector3.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16  copyright notice, this list of conditions and the
17  following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20  copyright notice, this list of conditions and the
21  following disclaimer in the documentation and/or other
22  materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25  contributors may be used to endorse or promote products
26  derived from this software without specific prior
27  written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
45 #pragma once
46 #ifndef AI_VECTOR3D_H_INC
47 #define AI_VECTOR3D_H_INC
48 
49 #ifdef __cplusplus
50 # include <cmath>
51 #else
52 # include <math.h>
53 #endif
54 
55 #include "defs.h"
56 
57 #ifdef __cplusplus
58 
59 template<typename TReal> class aiMatrix3x3t;
60 template<typename TReal> class aiMatrix4x4t;
61 
62 // ---------------------------------------------------------------------------
64 template <typename TReal>
65 class aiVector3t
66 {
67 public:
68  aiVector3t() : x(), y(), z() {}
69  aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
70  explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
71  aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
72 
73 public:
74 
75  // combined operators
76  const aiVector3t& operator += (const aiVector3t& o);
77  const aiVector3t& operator -= (const aiVector3t& o);
78  const aiVector3t& operator *= (TReal f);
79  const aiVector3t& operator /= (TReal f);
80 
81  // transform vector by matrix
82  aiVector3t& operator *= (const aiMatrix3x3t<TReal>& mat);
83  aiVector3t& operator *= (const aiMatrix4x4t<TReal>& mat);
84 
85  // access a single element
86  TReal operator[](unsigned int i) const;
87  TReal& operator[](unsigned int i);
88 
89  // comparison
90  bool operator== (const aiVector3t& other) const;
91  bool operator!= (const aiVector3t& other) const;
92  bool operator < (const aiVector3t& other) const;
93 
94  bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const;
95 
96  template <typename TOther>
97  operator aiVector3t<TOther> () const;
98 
99 public:
104  void Set( TReal pX, TReal pY, TReal pZ);
105 
108  TReal SquareLength() const;
109 
112  TReal Length() const;
113 
114 
116  aiVector3t& Normalize();
117 
119  aiVector3t& NormalizeSafe();
120 
125  const aiVector3t SymMul(const aiVector3t& o);
126 
127  TReal x, y, z;
128 };
129 
130 
131 typedef aiVector3t<ai_real> aiVector3D;
132 
133 #else
134 
135 struct aiVector3D {
136  ai_real x, y, z;
137 };
138 
139 #endif // __cplusplus
140 
141 #ifdef __cplusplus
142 
143 #endif // __cplusplus
144 
145 #endif // AI_VECTOR3D_H_INC
Assimp build configuration setup.
GLM_FUNC_DECL GLM_CONSTEXPR genType epsilon()
Return the epsilon constant for floating point types.
Definition: scalar_constants.inl:6
Definition: vector3.h:135
GLM_FUNC_DECL GLM_CONSTEXPR genType e()
Return e constant.
Definition: constants.inl:102