Changeset 13 in flairdev for trunk/include/FlairCore/Vector3D.h
 Timestamp:
 Apr 8, 2016, 3:39:24 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

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