libalmath  1.14
 All Classes Namespaces Functions Variables Typedefs Groups Pages
Public Member Functions | Public Attributes
AL::Math::Position2D Struct Reference

Create and play with a Position2D. More...

#include <alposition2d.h>

List of all members.

Public Member Functions

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

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
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

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
Position2D AL::Math::Position2D::operator+ ( const Position2D pPos2) const

Overloading of operator + for Position2D.

Parameters:
pPos2the second Position2D
Position2D AL::Math::Position2D::operator+ ( ) const

Overloading of operator + for Position2D.

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

Overloading of operator - for Position2D.

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

Overloading of operator - for Position2D.

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
std::vector<float> AL::Math::Position2D::toVector ( ) const

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


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: