Flair
Framework Libre Air
Vector2D.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}
13 #ifndef VECTOR2D_H
14 #define VECTOR2D_H
15 
16 namespace flair {
17 namespace core {
18 
23 template <typename T>
24 class Vector2D {
25 public:
34  Vector2D(T x = 0, T y = 0);
35 
40  ~Vector2D();
41 
47  void Rotate(float value);
48 
54  void RotateDeg(float value);
55 
61  float GetNorm(void) const;
62 
66  void Normalize(void);
67 
76  void Saturate(Vector2D<T> min, Vector2D<T> max);
77 
86  void Saturate(float min, float max);
87 
95  void Saturate(const Vector2D<T> &value);
96 
104  void Saturate(float value);
105 
109  T x;
110 
114  T y;
115 
116  template<typename S> Vector2D<T> &operator=(const Vector2D<S> &vector) {
117  x = vector.x;
118  y = vector.y;
119  return (*this);
120  }
121  Vector2D<T> &operator+=(const Vector2D<T> &vector);
122  Vector2D<T> &operator-=(const Vector2D<T> &vector);
123 };
124 
125 typedef Vector2D<float> Vector2Df;
126 
134 template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
135 
143 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
144 
153 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA);
154 
163 template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff);
164 
173 template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff);
174 
183 template<typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector);
184 
185 } // end namespace core
186 } // end namespace flair
187 
188 #endif // VECTOR2D_H
~Vector2D()
Destructor.
namespace of the flair Framework
Definition: Ahrs.h:19
void RotateDeg(float value)
Rotation.
void Normalize(void)
Normalize.
Class defining a 2D vector.
Definition: Vector2D.h:24
T x
x
Definition: Vector2D.h:109
void Rotate(float value)
Rotation.
float GetNorm(void) const
Norm.
T y
y
Definition: Vector2D.h:114
void Saturate(Vector2D< T > min, Vector2D< T > max)
Saturate.
Vector2D< T > operator/(const Vector2D< T > &vector, float coeff)
Divid.
Quaternion operator*(Quaternion const &quaternionA, Quaternion const &quaterniontB)
Multiply.
Quaternion operator-(Quaternion const &quaternionA, Quaternion const &quaterniontB)
Substract.
Vector2D(T x=0, T y=0)
Constructor.
Quaternion operator+(Quaternion const &quaterniontA, Quaternion const &quaterniontB)
Add.