source: flair-src/trunk/lib/FlairCore/src/Vector3D.h@ 15

Last change on this file since 15 was 15, checked in by Bayard Gildas, 6 years ago

sources reformatted with flair-format-dir script

File size: 4.9 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/*!
7 * \file Vector3D.h
8 * \brief Class defining a 3D vector
9 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
10 * \date 2013/05/02
11 * \version 4.0
12 */
13#ifndef VECTOR3D_H
14#define VECTOR3D_H
15
16#include <stddef.h>
17
18namespace flair {
19namespace core {
20class Vector2D;
21class RotationMatrix;
22class Quaternion;
23
24/*! \class Vector3D
25*
26* \brief Class defining a 3D vector
27*/
28class Vector3D {
29public:
30 /*!
31 * \brief Constructor
32 *
33 * Construct a Vector3D using specified values.
34 *
35 * \param x
36 * \param y
37 * \param z
38 */
39 Vector3D(float x = 0, float y = 0, float z = 0);
40
41 /*!
42 * \brief Destructor
43 *
44 */
45 ~Vector3D();
46
47 /*!
48 * \brief x
49 */
50 float x;
51
52 /*!
53 * \brief y
54 */
55 float y;
56
57 /*!
58 * \brief z
59 */
60 float z;
61
62 /*!
63 * \brief x axis rotation
64 *
65 * \param value rotation value in radians
66 */
67 void RotateX(float value);
68
69 /*!
70 * \brief x axis rotation
71 *
72 * \param value rotation value in degrees
73 */
74 void RotateXDeg(float value);
75
76 /*!
77 * \brief y axis rotation
78 *
79 * \param value rotation value in radians
80 */
81 void RotateY(float value);
82
83 /*!
84 * \brief y axis rotation
85 *
86 * \param value rotation value in degrees
87 */
88 void RotateYDeg(float value);
89
90 /*!
91 * \brief z axis rotation
92 *
93 * \param value rotation value in radians
94 */
95 void RotateZ(float value);
96
97 /*!
98 * \brief z axis rotation
99 *
100 * \param value rotation value in degrees
101 */
102 void RotateZDeg(float value);
103
104 /*!
105 * \brief rotation
106 *
107 * \param matrix rotation matrix
108 */
109 void Rotate(const RotationMatrix &matrix);
110
111 /*!
112 * \brief rotation
113 *
114 * Compute a rotation from a quaternion. This method uses a rotation matrix
115 * internaly.
116 *
117 * \param quaternion quaternion
118 */
119 void Rotate(const Quaternion &quaternion);
120
121 /*!
122 * \brief Convert to a Vector2D
123 *
124 * Uses x and y coordinates.
125 *
126 * \param vector destination
127 */
128 void To2Dxy(Vector2D &vector) const;
129
130 /*!
131 * \brief Convert to a Vector2D
132 *
133 * Uses x and y coordinates.
134 *
135 * \return destination
136 */
137 Vector2D To2Dxy(void) const;
138
139 /*!
140 * \brief Norm
141 *
142 * \return value
143 */
144 float GetNorm(void) const;
145
146 /*!
147 * \brief Normalize
148 */
149 void Normalize(void);
150
151 /*!
152 * \brief Saturate
153 *
154 * Saturate between min and max
155 *
156 * \param min minimum value
157 * \param max maximum value
158 */
159 void Saturate(const Vector3D &min, const Vector3D &max);
160
161 /*!
162 * \brief Saturate
163 *
164 * Saturate between min and max
165 *
166 * \param min minimum Vector3D(min,min,min) value
167 * \param max maximum Vector3D(max,max,max) value
168 */
169 void Saturate(float min, float max);
170
171 /*!
172 * \brief Saturate
173 *
174 * Saturate between -abs(value) and abs(value)
175 *
176 * \param value saturation Vector3D value
177 */
178 void Saturate(const Vector3D &value);
179
180 /*!
181 * \brief Saturate
182 *
183 * Saturate between -abs(Vector3D(value,value,value)) and
184 *abs(Vector3D(value,value,value))
185 *
186 * \param value saturation Vector3D(value,value,value)
187 */
188 void Saturate(float value);
189
190 float &operator[](size_t idx);
191 const float &operator[](size_t idx) const;
192 Vector3D &operator=(const Vector3D &vector);
193 Vector3D &operator+=(const Vector3D &vector);
194 Vector3D &operator-=(const Vector3D &vector);
195
196private:
197};
198
199/*! Add
200*
201* \brief Add
202*
203* \param vectorA vector
204* \param vectorB vector
205*
206* \return vectorA+vectorB
207*/
208Vector3D operator+(const Vector3D &vectorA, const Vector3D &vectorB);
209
210/*! Substract
211*
212* \brief Substract
213*
214* \param vectorA vector
215* \param vectorB vector
216*
217* \return vectorA-vectorB
218*/
219Vector3D operator-(const Vector3D &vectorA, const Vector3D &vectorB);
220
221/*! Minus
222*
223* \brief Minus
224*
225* \param vector vector
226*
227* \return -vector
228*/
229Vector3D operator-(const Vector3D &vector);
230
231/*! Divid
232*
233* \brief Divid
234*
235* \param vector vector
236* \param coeff coefficent
237*
238* \return vector/coefficient
239*/
240Vector3D operator/(const Vector3D &vector, float coeff);
241
242/*! Hadamard product
243*
244* \brief Hadamard product
245*
246* \param vectorA vector
247* \param vectorBA vector
248*
249* \return Hadamard product
250*/
251Vector3D operator*(const Vector3D &vectorA, const Vector3D &vectorB);
252
253/*! Multiply
254*
255* \brief Multiply
256*
257* \param vector vector
258* \param coeff coefficent
259*
260* \return coefficient*vector
261*/
262Vector3D operator*(const Vector3D &vector, float coeff);
263
264/*! Multiply
265*
266* \brief Multiply
267*
268* \param coeff coefficent
269* \param vector vector
270*
271* \return coefficient*vector
272*/
273Vector3D operator*(float coeff, const Vector3D &vector);
274
275/*! Cross product
276*
277* \brief Cross product
278*
279* \param vectorA first vector
280* \param vectorB second vector
281*
282* \return cross product
283*/
284Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D &vectorB);
285
286/*! Dot product
287*
288* \brief Dot product
289*
290* \param vectorA first vector
291* \param vectorB second vector
292*
293* \return dot product
294*/
295float DotProduct(const Vector3D &vectorA, const Vector3D &vectorB);
296
297} // end namespace core
298} // end namespace flair
299
300#endif // VECTOR3D_H
Note: See TracBrowser for help on using the repository browser.