Path Tracer
vector3.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 
9 
10 All rights reserved.
11 
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions 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 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
46 #pragma once
47 #ifndef AI_VECTOR3D_H_INC
48 #define AI_VECTOR3D_H_INC
49 
50 #ifdef __GNUC__
51 # pragma GCC system_header
52 #endif
53 
54 #ifdef __cplusplus
55 # include <cmath>
56 #else
57 # include <math.h>
58 #endif
59 
60 #include <assimp/defs.h>
61 
62 #ifdef __cplusplus
63 
64 template<typename TReal> class aiMatrix3x3t;
65 template<typename TReal> class aiMatrix4x4t;
66 
67 // ---------------------------------------------------------------------------
69 template <typename TReal>
70 class aiVector3t {
71 public:
72  aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
73  aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
74  explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
75  aiVector3t( const aiVector3t& o ) = default;
76 
77  // combined operators
78  const aiVector3t& operator += (const aiVector3t& o);
79  const aiVector3t& operator -= (const aiVector3t& o);
80  const aiVector3t& operator *= (TReal f);
81  const aiVector3t& operator /= (TReal f);
82 
83  // transform vector by matrix
84  aiVector3t& operator *= (const aiMatrix3x3t<TReal>& mat);
85  aiVector3t& operator *= (const aiMatrix4x4t<TReal>& mat);
86 
87  // access a single element
88  TReal operator[](unsigned int i) const;
89  TReal& operator[](unsigned int i);
90 
91  // comparison
92  bool operator== (const aiVector3t& other) const;
93  bool operator!= (const aiVector3t& other) const;
94  bool operator < (const aiVector3t& other) const;
95 
96  bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const;
97 
98  template <typename TOther>
99  operator aiVector3t<TOther> () const;
100 
105  void Set( TReal pX, TReal pY, TReal pZ);
106 
109  TReal SquareLength() const;
110 
113  TReal Length() const;
114 
115 
117  aiVector3t& Normalize();
118 
120  aiVector3t& NormalizeSafe();
121 
126  const aiVector3t SymMul(const aiVector3t& o);
127 
128  TReal x, y, z;
129 };
130 
131 
132 typedef aiVector3t<ai_real> aiVector3D;
133 
134 #else
135 
136 struct aiVector3D {
137  ai_real x, y, z;
138 };
139 
140 #endif // __cplusplus
141 
142 #ifdef __cplusplus
143 
144 #endif // __cplusplus
145 
146 #endif // AI_VECTOR3D_H_INC
aiVector3D
Definition: vector3.h:136
vector2.h
2D vector structure, including operators when compiling in C++
defs.h
Assimp build configuration setup. See the notes in the comment blocks to find out how to customize yo...
Eigen::UniformScaling::operator*
operator*(const MatrixBase< Derived > &matrix, const UniformScaling< Scalar > &s)
Definition: Scaling.h:135