[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
[15] | 16 | namespace flair {
|
---|
| 17 | namespace core {
|
---|
[2] | 18 |
|
---|
[15] | 19 | /*! \class Vector2D
|
---|
| 20 | *
|
---|
| 21 | * \brief Class defining a 2D vector
|
---|
| 22 | */
|
---|
| 23 | class Vector2D {
|
---|
| 24 | public:
|
---|
| 25 | /*!
|
---|
| 26 | * \brief Constructor
|
---|
| 27 | *
|
---|
| 28 | * Construct a Vector2D using specified values.
|
---|
| 29 | *
|
---|
| 30 | * \param x
|
---|
| 31 | * \param y
|
---|
| 32 | */
|
---|
| 33 | Vector2D(float x = 0, float y = 0);
|
---|
[2] | 34 |
|
---|
[15] | 35 | /*!
|
---|
| 36 | * \brief Destructor
|
---|
| 37 | *
|
---|
| 38 | */
|
---|
| 39 | ~Vector2D();
|
---|
[2] | 40 |
|
---|
[15] | 41 | /*!
|
---|
| 42 | * \brief Rotation
|
---|
| 43 | *
|
---|
| 44 | * \param value rotation value in radians
|
---|
| 45 | */
|
---|
| 46 | void Rotate(float value);
|
---|
[2] | 47 |
|
---|
[15] | 48 | /*!
|
---|
| 49 | * \brief Rotation
|
---|
| 50 | *
|
---|
| 51 | * \param value rotation value in degrees
|
---|
| 52 | */
|
---|
| 53 | void RotateDeg(float value);
|
---|
[2] | 54 |
|
---|
[15] | 55 | /*!
|
---|
| 56 | * \brief Norm
|
---|
| 57 | *
|
---|
| 58 | * \return value
|
---|
| 59 | */
|
---|
| 60 | float GetNorm(void) const;
|
---|
[2] | 61 |
|
---|
[15] | 62 | /*!
|
---|
| 63 | * \brief Normalize
|
---|
| 64 | */
|
---|
| 65 | void Normalize(void);
|
---|
[2] | 66 |
|
---|
[15] | 67 | /*!
|
---|
| 68 | * \brief Saturate
|
---|
| 69 | *
|
---|
| 70 | * Saturate between min and max
|
---|
| 71 | *
|
---|
| 72 | * \param min minimum Vector2D value
|
---|
| 73 | * \param max maximum Vector2D value
|
---|
| 74 | */
|
---|
| 75 | void Saturate(Vector2D min, Vector2D max);
|
---|
[2] | 76 |
|
---|
[15] | 77 | /*!
|
---|
| 78 | * \brief Saturate
|
---|
| 79 | *
|
---|
| 80 | * Saturate between min and max
|
---|
| 81 | *
|
---|
| 82 | * \param min minimum Vector2D(min,min) value
|
---|
| 83 | * \param max maximum Vector2D(max,max) value
|
---|
| 84 | */
|
---|
| 85 | void Saturate(float min, float max);
|
---|
[2] | 86 |
|
---|
[15] | 87 | /*!
|
---|
| 88 | * \brief Saturate
|
---|
| 89 | *
|
---|
| 90 | * Saturate between -abs(value) and abs(value)
|
---|
| 91 | *
|
---|
| 92 | * \param value saturation Vector2D value
|
---|
| 93 | */
|
---|
| 94 | void Saturate(const Vector2D &value);
|
---|
[2] | 95 |
|
---|
[15] | 96 | /*!
|
---|
| 97 | * \brief Saturate
|
---|
| 98 | *
|
---|
| 99 | * Saturate between -abs(Vector2D(value,value)) and abs(Vector2D(value,value))
|
---|
| 100 | *
|
---|
| 101 | * \param value saturation Vector2D(value,value)
|
---|
| 102 | */
|
---|
| 103 | void Saturate(float value);
|
---|
[2] | 104 |
|
---|
[15] | 105 | /*!
|
---|
| 106 | * \brief x
|
---|
| 107 | */
|
---|
| 108 | float x;
|
---|
[2] | 109 |
|
---|
[15] | 110 | /*!
|
---|
| 111 | * \brief y
|
---|
| 112 | */
|
---|
| 113 | float y;
|
---|
[2] | 114 |
|
---|
[15] | 115 | Vector2D &operator=(const Vector2D &vector);
|
---|
| 116 | };
|
---|
[2] | 117 |
|
---|
[15] | 118 | /*! Add
|
---|
| 119 | *
|
---|
| 120 | * \brief Add
|
---|
| 121 | *
|
---|
| 122 | * \param vectorA vector
|
---|
| 123 | * \param vectorB vector
|
---|
| 124 | */
|
---|
| 125 | Vector2D operator+(const Vector2D &vectorA, const Vector2D &vectorB);
|
---|
[2] | 126 |
|
---|
[15] | 127 | /*! Substract
|
---|
| 128 | *
|
---|
| 129 | * \brief Substract
|
---|
| 130 | *
|
---|
| 131 | * \param vectorA vector
|
---|
| 132 | * \param vectorB vector
|
---|
| 133 | */
|
---|
| 134 | Vector2D operator-(const Vector2D &vectorA, const Vector2D &vectorB);
|
---|
[2] | 135 |
|
---|
[15] | 136 | /*! Divid
|
---|
| 137 | *
|
---|
| 138 | * \brief Divid
|
---|
| 139 | *
|
---|
| 140 | * \param vector vector
|
---|
| 141 | * \param coeff coefficent
|
---|
| 142 | * \return vector/coefficient
|
---|
| 143 | */
|
---|
| 144 | Vector2D operator/(const Vector2D &vector, float coeff);
|
---|
[2] | 145 |
|
---|
[15] | 146 | /*! Multiply
|
---|
| 147 | *
|
---|
| 148 | * \brief Multiplyf
|
---|
| 149 | *
|
---|
| 150 | * \param vector vector
|
---|
| 151 | * \param coeff coefficent
|
---|
| 152 | * \return coefficient*vector
|
---|
| 153 | */
|
---|
| 154 | Vector2D operator*(const Vector2D &vector, float coeff);
|
---|
[2] | 155 |
|
---|
[15] | 156 | /*! Multiply
|
---|
| 157 | *
|
---|
| 158 | * \brief Multiply
|
---|
| 159 | *
|
---|
| 160 | * \param coeff coefficent
|
---|
| 161 | * \param vector vector
|
---|
| 162 | * \return coefficient*vector
|
---|
| 163 | */
|
---|
| 164 | Vector2D operator*(float coeff, const Vector2D &vector);
|
---|
[2] | 165 |
|
---|
| 166 | } // end namespace core
|
---|
| 167 | } // end namespace flair
|
---|
| 168 |
|
---|
| 169 | #endif // VECTOR2D_H
|
---|