Flair
Framework Libre Air
Vector3D.h
Go to the documentation of this file.
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
5 
13 #ifndef VECTOR3D_H
14 #define VECTOR3D_H
15 
16 #include <stddef.h>
17 #include <Vector2D.h>
18 
19 namespace flair {
20 namespace core {
21 class RotationMatrix;
22 class Quaternion;
23 
28 template <typename T>
29 class Vector3D {
30 public:
40  Vector3D(T x = 0, T y = 0, T z = 0);
41 
46  ~Vector3D();
47 
51  T x;
52 
56  T y;
57 
61  T z;
62 
68  void RotateX(float value);
69 
75  void RotateXDeg(float value);
76 
82  void RotateY(float value);
83 
89  void RotateYDeg(float value);
90 
96  void RotateZ(float value);
97 
103  void RotateZDeg(float value);
104 
110  void Rotate(const RotationMatrix &matrix);
111 
120  void Rotate(const Quaternion &quaternion);
121 
129  void To2Dxy(Vector2D<T> &vector) const;
130 
138  Vector2D<T> To2Dxy(void) const;
139 
145  float GetNorm(void) const;
146 
150  void Normalize(void);
151 
160  void Saturate(const Vector3D<T> &min, const Vector3D<T> &max);
161 
170  void Saturate(float min, float max);
171 
179  void Saturate(const Vector3D<T> &value);
180 
189  void Saturate(float value);
190 
191  T &operator[](size_t idx);
192  const T &operator[](size_t idx) const;
193  //Vector3D<T> &operator=(const Vector3D<T> &vector);
194  template<typename S> Vector3D<T> &operator=(const Vector3D<S> &vector) {
195  x = vector.x;
196  y = vector.y;
197  z = vector.z;
198  return (*this);
199  }
200  Vector3D<T> &operator+=(const Vector3D<T> &vector);
201  Vector3D<T> &operator-=(const Vector3D<T> &vector);
202 
203 private:
204 };
205 
206 typedef Vector3D<float> Vector3Df;
207 
217 template<typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
218 
228 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
229 
238 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vector);
239 
249 template<typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff);
250 
260 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
261 
271 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff);
272 
282 template<typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector);
283 
293 template<typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
294 
304 template<typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB);
305 
306 } // end namespace core
307 } // end namespace flair
308 
309 #endif // VECTOR3D_H
void Normalize(void)
Normalize.
void RotateYDeg(float value)
y axis rotation
namespace of the flair Framework
Definition: Ahrs.h:19
void RotateZ(float value)
z axis rotation
Class defining a 3D vector.
Definition: Vector3D.h:29
Class defining a 2D vector.
Definition: Vector2D.h:24
Class defining a rotation matrix.
Definition: RotationMatrix.h:26
~Vector3D()
Destructor.
void RotateZDeg(float value)
z axis rotation
Class defining a 2D vector.
void Saturate(const Vector3D< T > &min, const Vector3D< T > &max)
Saturate.
T y
y
Definition: Vector3D.h:56
Vector2D< T > To2Dxy(void) const
Convert to a Vector2D.
void RotateY(float value)
y axis rotation
void Rotate(const RotationMatrix &matrix)
rotation
Vector2D< T > operator/(const Vector2D< T > &vector, float coeff)
Divid.
void RotateXDeg(float value)
x axis rotation
T z
z
Definition: Vector3D.h:61
Quaternion operator*(Quaternion const &quaternionA, Quaternion const &quaterniontB)
Multiply.
Quaternion operator-(Quaternion const &quaternionA, Quaternion const &quaterniontB)
Substract.
float DotProduct(const Vector3D< T > &vectorA, const Vector3D< T > &vectorB)
Dot product.
T x
x
Definition: Vector3D.h:51
Vector3D< T > CrossProduct(const Vector3D< T > &vectorA, const Vector3D< T > &vectorB)
Cross product.
float GetNorm(void) const
Norm.
Vector3D(T x=0, T y=0, T z=0)
Constructor.
void RotateX(float value)
x axis rotation
Quaternion operator+(Quaternion const &quaterniontA, Quaternion const &quaterniontB)
Add.
Class defining a quaternion.
Definition: Quaternion.h:26