source: flair-dev/trunk/include/FlairCore/Vector2D.h @ 76

Last change on this file since 76 was 50, checked in by Sanahuja Guillaume, 3 years ago

doc

File size: 3.3 KB
Line 
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/*!
6 * \file Vector2D.h
7 * \brief Class defining a 2D vector
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2013/05/02
10 * \version 4.0
11 */
12
13#ifndef VECTOR2D_H
14#define VECTOR2D_H
15
16namespace flair {
17namespace core {
18
19/*! \class Vector2D
20*
21* \brief Class defining a 2D vector
22*/
23template <typename T>
24class Vector2D {
25public:
26  /*!
27  * \brief Constructor
28  *
29  * Construct a Vector2D using specified values.
30  *
31  * \param x
32  * \param y
33  */
34  Vector2D(T x = 0, T y = 0);
35
36  /*!
37  * \brief Destructor
38  *
39  */
40  ~Vector2D();
41
42  /*!
43  * \brief Rotation
44  *
45  * \param value rotation value in radians
46  */
47  void Rotate(float value);
48
49  /*!
50  * \brief Rotation
51  *
52  * \param value rotation value in degrees
53  */
54  void RotateDeg(float value);
55
56  /*!
57  * \brief Norm
58  *
59  * \return value
60  */
61  float GetNorm(void) const;
62
63  /*!
64  * \brief Normalize
65  */
66  void Normalize(void);
67
68  /*!
69  * \brief Saturate
70  *
71  * Saturate between min and max
72  *
73  * \param min minimum Vector2D value
74  * \param max maximum Vector2D value
75  */
76  void Saturate(Vector2D<T> min, Vector2D<T> max);
77
78  /*!
79  * \brief Saturate
80  *
81  * Saturate between min and max
82  *
83  * \param min minimum Vector2D(min,min) value
84  * \param max maximum Vector2D(max,max) value
85  */
86  void Saturate(float min, float max);
87
88  /*!
89  * \brief Saturate
90  *
91  * Saturate between -abs(value) and abs(value)
92  *
93  * \param value saturation Vector2D value
94  */
95  void Saturate(const Vector2D<T> &value);
96
97  /*!
98  * \brief Saturate
99  *
100  * Saturate between -abs(Vector2D(value,value)) and abs(Vector2D(value,value))
101  *
102  * \param value saturation Vector2D(value,value)
103  */
104  void Saturate(float value);
105
106  /*!
107  * \brief x
108  */
109  T x;
110
111  /*!
112  * \brief y
113  */
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
125typedef Vector2D<float> Vector2Df;
126
127/*! Add
128*
129* \brief Add
130*
131* \param vectorA vector
132* \param vectorB vector
133*/
134template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
135
136/*! Substract
137*
138* \brief Substract
139*
140* \param vectorA vector
141* \param vectorB vector
142*/
143template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB);
144
145/*! Opposite
146*
147* \brief Opposite
148*
149* \param vectorA vector
150*
151* \return -vectorA
152*/
153template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA);
154
155/*! Divid
156*
157* \brief Divid
158*
159* \param vector vector
160* \param coeff coefficent
161* \return vector/coefficient
162*/
163template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff);
164
165/*! Multiply
166*
167* \brief Multiplyf
168*
169* \param vector vector
170* \param coeff coefficent
171* \return coefficient*vector
172*/
173template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff);
174
175/*! Multiply
176*
177* \brief Multiply
178*
179* \param coeff coefficent
180* \param vector vector
181* \return coefficient*vector
182*/
183template<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
Note: See TracBrowser for help on using the repository browser.