My Project
Public Member Functions | List of all members
Position Class Reference

3 dimension Position class (x, y, z) More...

#include <Position.hpp>

Public Member Functions

 Position (float x, float y, float z=0)
 Construct a new Position object from positions sent as parameter. More...
 
 Position (Position const &position)
 Construct a new object from other Position object sent as parameter. More...
 
 Position ()
 Construct a new Position object from default values.
 
 ~Position ()
 Destroy the Position object.
 
bool operator== (Position const &position)
 Check if all positions are the same (x, y z) More...
 
PositionsetFromArray (std::array< float, 3 > const &position)
 Set x, y, z from other float array. More...
 
Positionoperator= (Position const &position)
 Set x, y, z from other Postition object. More...
 
Positionoperator= (float pos)
 Set x, y, z from a value. More...
 
Position operator+ (float value)
 Overload the + operator. More...
 
Position operator+ (Position const &position)
 Overload the + operator for Position objects. More...
 
Position operator- (float value)
 Overload the - operator. More...
 
Position operator- (Position const &position)
 Overload the - operator for Position objects. More...
 
Position operator* (float value)
 Overload the * operator. More...
 
Position operator* (Position const &position)
 Overload the * operator for Position objects. More...
 
Positionoperator+= (Position const &position)
 Add to x, y, z respectively the x, y, z of the Position object sent as parameter. More...
 
Positionoperator+= (float number)
 Add to x, y, z a value. More...
 
Positionoperator-= (Position const &position)
 Substract to x, y, z respectively the x, y, z of the Position object sent as parameter. More...
 
Positionoperator-= (float number)
 Substract to x, y, z a value. More...
 
Positionoperator*= (Position const &position)
 multiply to x, y, z respectively the x, y, z of the Position object sent as parameter More...
 
Positionoperator*= (float number)
 multiply to x, y, z a value More...
 
Positionoperator/= (Position const &position)
 divide to x, y, z respectively the x, y, z of the Position object sent as parameter More...
 
Positionoperator/= (float number)
 divide to x, y, z a value More...
 
void setPosition (float x, float y)
 Set the position. More...
 
void setPosition (float x, float y, float z)
 Set the position. More...
 
void setPosition (Position const &position)
 Set the position. More...
 
void setX (float x)
 set x value More...
 
void setY (float y)
 set y value More...
 
void setZ (float z)
 set z value More...
 
void reset ()
 reset x, y, z to 0 More...
 
std::array< float, 3 > getPosition () const
 Get x, y, z position in an array. More...
 
float getX () const
 get x value More...
 
float getY () const
 get y value More...
 
float getZ () const
 get z value More...
 
Vector3 getVector3 () const
 Get the Vector3 object from Position values. More...
 
Vector2 getVector2 () const
 Get the Vector2 object from Position values. More...
 

Detailed Description

3 dimension Position class (x, y, z)

Constructor & Destructor Documentation

◆ Position() [1/2]

Position::Position ( float  x,
float  y,
float  z = 0 
)

Construct a new Position object from positions sent as parameter.

Parameters
xposition x value
yposition y value
zposition z value

◆ Position() [2/2]

Position::Position ( Position const &  position)

Construct a new object from other Position object sent as parameter.

Parameters
positionother Position object where we get x, y, z value

Member Function Documentation

◆ getPosition()

std::array< float, 3 > Position::getPosition ( ) const

Get x, y, z position in an array.

Returns
std::array<float, 3> array of x, y, z

◆ getVector2()

Vector2 Position::getVector2 ( ) const

Get the Vector2 object from Position values.

Returns
Vector2 object with x, y corresponding of x, y of Position object

◆ getVector3()

Vector3 Position::getVector3 ( ) const

Get the Vector3 object from Position values.

Returns
Vector3 object with x, y, z corresponding of x, y, z of Position object

◆ getX()

float Position::getX ( ) const

get x value

Returns
float x value

◆ getY()

float Position::getY ( ) const

get y value

Returns
float y value

◆ getZ()

float Position::getZ ( ) const

get z value

Returns
float z value

◆ operator*() [1/2]

Position Position::operator* ( float  value)

Overload the * operator.

Parameters
valueFloat to multiply
Returns
Position New Position

◆ operator*() [2/2]

Position Position::operator* ( Position const &  position)

Overload the * operator for Position objects.

Parameters
positionPosition to multiply
Returns
Position New position

◆ operator*=() [1/2]

Position & Position::operator*= ( float  number)

multiply to x, y, z a value

Parameters
numberThe value to multiply
Returns
Position& himself

◆ operator*=() [2/2]

Position & Position::operator*= ( Position const &  position)

multiply to x, y, z respectively the x, y, z of the Position object sent as parameter

Parameters
positionPosition object containing x, y, z to multiply
Returns
Position& himself

◆ operator+() [1/2]

Position Position::operator+ ( float  value)

Overload the + operator.

Parameters
valueFloat to add to position
Returns
Position& Himself

◆ operator+() [2/2]

Position Position::operator+ ( Position const &  position)

Overload the + operator for Position objects.

Parameters
positionPosition to add
Returns
Position New Position

◆ operator+=() [1/2]

Position & Position::operator+= ( float  number)

Add to x, y, z a value.

Parameters
numberThe value to add
Returns
Position& himself

◆ operator+=() [2/2]

Position & Position::operator+= ( Position const &  position)

Add to x, y, z respectively the x, y, z of the Position object sent as parameter.

Parameters
positionPosition object containing x, y, z to add
Returns
Position& himself

◆ operator-() [1/2]

Position Position::operator- ( float  value)

Overload the - operator.

Parameters
valueFloat to reduce
Returns
Position New Position

◆ operator-() [2/2]

Position Position::operator- ( Position const &  position)

Overload the - operator for Position objects.

Parameters
positionPosition to reduce
Returns
Position New Position

◆ operator-=() [1/2]

Position & Position::operator-= ( float  number)

Substract to x, y, z a value.

Parameters
numberThe value to substract
Returns
Position& himself

◆ operator-=() [2/2]

Position & Position::operator-= ( Position const &  position)

Substract to x, y, z respectively the x, y, z of the Position object sent as parameter.

Parameters
positionPosition object containing x, y, z to substract
Returns
Position& himself

◆ operator/=() [1/2]

Position & Position::operator/= ( float  number)

divide to x, y, z a value

Exceptions
Error::PositionErrorif number is equal 0 (can't divide by 0)
Parameters
numberThe value to divide
Returns
Position& himself

◆ operator/=() [2/2]

Position & Position::operator/= ( Position const &  position)

divide to x, y, z respectively the x, y, z of the Position object sent as parameter

Exceptions
Error::PositionErrorif x, y or z of position is equal 0 (can't divide by 0)
Parameters
positionPosition object containing x, y, z to divide
Returns
Position& himself

◆ operator=() [1/2]

Position & Position::operator= ( float  pos)

Set x, y, z from a value.

Parameters
posvalue to set to x, y, z
Returns
Position& himself

◆ operator=() [2/2]

Position & Position::operator= ( Position const &  position)

Set x, y, z from other Postition object.

Parameters
positionPosition object from where we copy x, y, z value
Returns
Position& himself

◆ operator==()

bool Position::operator== ( Position const &  position)

Check if all positions are the same (x, y z)

Parameters
positionposition to compare with the element
Returns
true if all positions have the same value (x, y z)
false if some position have not the same value (x, y, z)

◆ reset()

void Position::reset ( )

reset x, y, z to 0

◆ setFromArray()

Position & Position::setFromArray ( std::array< float, 3 > const &  position)

Set x, y, z from other float array.

Parameters
positionarray from where we copy x, y, z value

◆ setPosition() [1/3]

void Position::setPosition ( float  x,
float  y 
)

Set the position.

Parameters
xnew x value
ynew y value

◆ setPosition() [2/3]

void Position::setPosition ( float  x,
float  y,
float  z 
)

Set the position.

Parameters
xnew x value
ynew y value
znew z value

◆ setPosition() [3/3]

void Position::setPosition ( Position const &  position)

Set the position.

Parameters
positionPosition object from where we get new x, y, z value

◆ setX()

void Position::setX ( float  x)

set x value

Parameters
xnew x value

◆ setY()

void Position::setY ( float  y)

set y value

Parameters
ynew y value

◆ setZ()

void Position::setZ ( float  z)

set z value

Parameters
znew z value

The documentation for this class was generated from the following files: