libalmath  2.5.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
AL::Math::Position2D Struct Reference

Create and play with a Position2D. More...

#include <alposition2d.h>

Public Member Functions

 Position2D ()
 Create a Position2D initialized with 0.0f. More...
 
 Position2D (float pInit)
 Create a Position2D initialize with the same float. More...
 
 Position2D (float pX, float pY)
 Create a Position2D initialized with explicit value. More...
 
 Position2D (const std::vector< float > &pFloats)
 Create a Position2D with an std::vector. More...
 
Position2D operator+ (const Position2D &pPos2) const
 Overloading of operator + for Position2D. More...
 
Position2D operator- (const Position2D &pPos2) const
 Overloading of operator - for Position2D. More...
 
Position2D operator+ (void) const
 Overloading of operator + for Position2D. More...
 
Position2D operator- () const
 Overloading of operator - for Position2D. More...
 
Position2Doperator+= (const Position2D &pPos2)
 Overloading of operator += for Position2D. More...
 
Position2Doperator-= (const Position2D &pPos2)
 Overloading of operator -= for Position2D. More...
 
bool operator== (const Position2D &pPos2) const
 Overloading of operator == for Position2D. More...
 
bool operator!= (const Position2D &pPos2) const
 Overloading of operator != for Position2D. More...
 
Position2D operator* (float pVal) const
 Overloading of operator * for Position2D. More...
 
Position2D operator/ (float pVal) const
 Overloading of operator / for Position2D. More...
 
Position2Doperator*= (float pVal)
 Overloading of operator *= for Position2D. More...
 
Position2Doperator/= (float pVal)
 Overloading of operator /= for Position2D. More...
 
float distanceSquared (const Position2D &pPos2) const
 Compute the squared distance between the actual Position2D and the one give in argument. More...
 
float distance (const Position2D &pPos2) const
 Compute the distance between the actual Position2D and the one give in argument. More...
 
bool isNear (const Position2D &pPos2, const float &pEpsilon=0.0001f) const
 Check if the actual Position2D is near the one give in argument. More...
 
float norm () const
 Compute the norm of the actual Position2D. More...
 
Position2D normalize () const
 Normalize the actual Position2D. More...
 
float dotProduct (const Position2D &pPos2) const
 Compute the dot Product between the actual Position2D and the one give in argument. More...
 
float crossProduct (const Position2D &pPos2) const
 Compute the cross Product between the actual Position2D and the one give in argument. More...
 
void toVector (std::vector< float > &pReturnVector) const
 Return the Position2D as a vector of float [x, y]. More...
 
std::vector< float > toVector (void) const
 
void writeToVector (std::vector< float >::iterator &pIt) const
 Write [x, y] in the vector and update the iterator. It is assumed the vector has enough space. More...
 
float getAngle () const
 Return the angular direction of a Position2D. More...
 

Static Public Member Functions

static Position2D fromPolarCoordinates (const float pRadius, const float pAngle)
 Build a Position2D from polar coordinates. More...
 

Public Attributes

float x
 
float y
 

Detailed Description

Create and play with a Position2D.

A Position2D is just defined by x and y.

Definition at line 23 of file alposition2d.h.

Constructor & Destructor Documentation

AL::Math::Position2D::Position2D ( )

Create a Position2D initialized with 0.0f.

$ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{c} 0.0 \\ 0.0 \end{array}\right]$

AL::Math::Position2D::Position2D ( float  pInit)
explicit

Create a Position2D initialize with the same float.

$ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{c} pInit \\ pInit \end{array}\right]$

Parameters
pInitthe float value for each member
AL::Math::Position2D::Position2D ( float  pX,
float  pY 
)

Create a Position2D initialized with explicit value.

$ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{c} pX \\ pY \end{array}\right]$

Parameters
pXthe float value for x
pYthe float value for y
AL::Math::Position2D::Position2D ( const std::vector< float > &  pFloats)

Create a Position2D with an std::vector.

$ \left[\begin{array}{c} x \\ y \end{array}\right] = \left[\begin{array}{c} pFloats[0] \\ pFloats[1] \end{array}\right]$

Parameters
pFloatsAn std::vector<float> of size 2 for respectively: x and y

Member Function Documentation

float AL::Math::Position2D::crossProduct ( const Position2D pPos2) const

Compute the cross Product between the actual Position2D and the one give in argument.

$pRes = (pPos1.x*pPos2.y - pPos1.y*pPos2.x)$

Parameters
pPos2the second Position2D
Returns
the float cross product between the two Position2D
float AL::Math::Position2D::distance ( const Position2D pPos2) const

Compute the distance between the actual Position2D and the one give in argument.

$\sqrt{(pPos1.x-pPos2.x)^2+(pPos1.y-pPos2.y)^2}$

Parameters
pPos2the second Position2D
Returns
the float distance between the two Position2D
float AL::Math::Position2D::distanceSquared ( const Position2D pPos2) const

Compute the squared distance between the actual Position2D and the one give in argument.

$(pPos1.x-pPos2.x)^2+(pPos1.y-pPos2.y)^2$

Parameters
pPos2the second Position2D
Returns
the float squared distance between the two Position2D
float AL::Math::Position2D::dotProduct ( const Position2D pPos2) const

Compute the dot Product between the actual Position2D and the one give in argument.

$result = (pPos1.x*pPos2.x + pPos1.y*pPos2.y)$

Parameters
pPos2the second Position2D
Returns
the float dot product between the two Position2D
static Position2D AL::Math::Position2D::fromPolarCoordinates ( const float  pRadius,
const float  pAngle 
)
static

Build a Position2D from polar coordinates.

Parameters
pRadiuspolar radius
pAnglepolar angle in radians
float AL::Math::Position2D::getAngle ( ) const

Return the angular direction of a Position2D.

$pRes = atan2(y, x)$

bool AL::Math::Position2D::isNear ( const Position2D pPos2,
const float &  pEpsilon = 0.0001f 
) const

Check if the actual Position2D is near the one give in argument.

Parameters
pPos2the second Position2D
pEpsilonan optionnal epsilon distance
Returns
true if the distance between the two Position2D is less than pEpsilon
float AL::Math::Position2D::norm ( ) const

Compute the norm of the actual Position2D.

$\sqrt{pPos.x^2+pPos.y^2}$

Returns
the float norm of the Position2D
Position2D AL::Math::Position2D::normalize ( ) const

Normalize the actual Position2D.

$pRes = \frac{pPos}{norm(pPos)}$

Returns
the Position2D normalized
bool AL::Math::Position2D::operator!= ( const Position2D pPos2) const

Overloading of operator != for Position2D.

Parameters
pPos2the second Position2D
Returns
true if one of each float of the two Position2D are not equal
Position2D AL::Math::Position2D::operator* ( float  pVal) const
inline

Overloading of operator * for Position2D.

Parameters
pValthe float factor

Definition at line 179 of file alposition2d.h.

Position2D& AL::Math::Position2D::operator*= ( float  pVal)

Overloading of operator *= for Position2D.

Parameters
pValthe float factor
Position2D AL::Math::Position2D::operator+ ( const Position2D pPos2) const
inline

Overloading of operator + for Position2D.

Parameters
pPos2the second Position2D

Definition at line 115 of file alposition2d.h.

Position2D AL::Math::Position2D::operator+ ( void  ) const
inline

Overloading of operator + for Position2D.

Definition at line 132 of file alposition2d.h.

Position2D& AL::Math::Position2D::operator+= ( const Position2D pPos2)

Overloading of operator += for Position2D.

Parameters
pPos2the second Position2D
Position2D AL::Math::Position2D::operator- ( const Position2D pPos2) const
inline

Overloading of operator - for Position2D.

Parameters
pPos2the second Position2D

Definition at line 124 of file alposition2d.h.

Position2D AL::Math::Position2D::operator- ( ) const
inline

Overloading of operator - for Position2D.

Definition at line 140 of file alposition2d.h.

Position2D& AL::Math::Position2D::operator-= ( const Position2D pPos2)

Overloading of operator -= for Position2D.

Parameters
pPos2the second Position2D
Position2D AL::Math::Position2D::operator/ ( float  pVal) const

Overloading of operator / for Position2D.

Parameters
pValthe float factor
Position2D& AL::Math::Position2D::operator/= ( float  pVal)

Overloading of operator /= for Position2D.

Parameters
pValthe float factor
bool AL::Math::Position2D::operator== ( const Position2D pPos2) const

Overloading of operator == for Position2D.

Parameters
pPos2the second Position2D
Returns
true if each float of the two Position2D are equal
void AL::Math::Position2D::toVector ( std::vector< float > &  pReturnVector) const

Return the Position2D as a vector of float [x, y].

std::vector<float> AL::Math::Position2D::toVector ( void  ) const
void AL::Math::Position2D::writeToVector ( std::vector< float >::iterator &  pIt) const

Write [x, y] in the vector and update the iterator. It is assumed the vector has enough space.

Member Data Documentation

float AL::Math::Position2D::x

Definition at line 26 of file alposition2d.h.

float AL::Math::Position2D::y

Definition at line 28 of file alposition2d.h.


The documentation for this struct was generated from the following file: