libalmath
1.12
|
00001 /* 00002 ** Author(s): 00003 ** - Chris Kilner 00004 ** - Cyrille Collette 00005 ** - David Gouaillier 00006 ** 00007 ** Copyright (C) 2011 Aldebaran Robotics 00008 */ 00009 00010 00011 #pragma once 00012 #ifndef _LIBALMATH_ALMATH_TYPES_ALPOSITION2D_H_ 00013 #define _LIBALMATH_ALMATH_TYPES_ALPOSITION2D_H_ 00014 00015 #include <vector> 00016 00017 namespace AL { 00018 namespace Math { 00019 00026 struct Position2D 00027 { 00029 float x; 00031 float y; 00032 00035 00046 00047 Position2D(); 00048 00051 00062 00063 00064 00065 explicit Position2D(float pInit); 00066 00069 00080 00081 00082 00083 Position2D(float pX, float pY); 00084 00087 00098 00099 00100 00101 00102 00103 Position2D(const std::vector<float>& pFloats); 00104 00109 Position2D operator+ (const Position2D& pPos2) const; 00110 00115 Position2D operator- (const Position2D& pPos2) const; 00116 00120 Position2D operator+ () const; 00121 00125 Position2D operator- () const; 00126 00131 Position2D& operator+= (const Position2D& pPos2); 00132 00137 Position2D& operator-= (const Position2D& pPos2); 00138 00146 bool operator==(const Position2D& pPos2) const; 00147 00155 bool operator!=(const Position2D& pPos2) const; 00156 00161 Position2D operator* (float pVal) const; 00162 00167 Position2D operator/ (float pVal) const; 00168 00173 Position2D& operator*= (float pVal); 00174 00179 Position2D& operator/= (float pVal); 00180 00191 float distanceSquared(const Position2D& pPos2) const; 00192 00203 float distance(const Position2D& pPos2) const; 00204 00214 bool isNear( 00215 const Position2D& pPos2, 00216 const float& pEpsilon=0.0001f) const; 00217 00226 float norm() const; 00227 00236 Position2D normalize() const; 00237 00248 float crossProduct(const Position2D& pPos2) const; 00249 00253 std::vector<float> toVector() const; 00254 }; 00255 00256 // TODO : Need this ? 00257 Position2D operator* ( 00258 const float pM, 00259 const Position2D& pPos1); 00260 00272 float distanceSquared( 00273 const Position2D& pPos1, 00274 const Position2D& pPos2); 00275 00287 float distance( 00288 const Position2D& pPos1, 00289 const Position2D& pPos2); 00290 00301 float norm(const Position2D& pPos); 00302 00313 Position2D normalize(const Position2D& pPos); 00314 00326 float crossProduct( 00327 const Position2D& pPos1, 00328 const Position2D& pPos2); 00329 00340 void crossProduct( 00341 const Position2D& pPos1, 00342 const Position2D& pPos2, 00343 float& pRes); 00344 00345 } // end namespace math 00346 } // end namespace al 00347 #endif // _LIBALMATH_ALMATH_TYPES_ALPOSITION2D_H_