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