MachineIntelligenceCore:Algorithms
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mic::types::Position2D Class Reference

Class representing position in 2-D space. More...

#include <Position2D.hpp>

Public Member Functions

 Position2D ()
 
 Position2D (long x_, long y_)
 
 Position2D (size_t min_x_, size_t max_x_, size_t min_y_, size_t max_y_)
 
void rand (size_t min_x_, size_t max_x_, size_t min_y_, size_t max_y_)
 
void set (long x_, long y_)
 
mic::types::Position2D operator+ (Action2DInterface ac_)
 
bool operator== (mic::types::Position2D pos_)
 
bool move (Action2DInterface ac_)
 
bool move (Action2DInterface ac_, size_t width_, size_t height_, bool circular_world_=true)
 

Public Attributes

long x
 The x coordinate. More...
 
long y
 The y coordinate. More...
 

Friends

std::ostream & operator<< (std::ostream &os_, const Position2D &pos_)
 

Detailed Description

Class representing position in 2-D space.

Author
tkornuta

Definition at line 35 of file Position2D.hpp.

Constructor & Destructor Documentation

mic::types::Position2D::Position2D ( )
inline

Default constructor. Sets position to (0,0).

Definition at line 47 of file Position2D.hpp.

mic::types::Position2D::Position2D ( long  x_,
long  y_ 
)
inline

Constructor. Sets position to (0,0).

Definition at line 52 of file Position2D.hpp.

mic::types::Position2D::Position2D ( size_t  min_x_,
size_t  max_x_,
size_t  min_y_,
size_t  max_y_ 
)
inline

Constructor responsible for generation of a random position.

Parameters
min_x_Min x cooridnate.
max_x_Max x cooridnate.
min_y_Min y cooridnate.
max_y_Max y cooridnate.

Definition at line 61 of file Position2D.hpp.

References rand().

Here is the call graph for this function:

Member Function Documentation

bool mic::types::Position2D::move ( Action2DInterface  ac_)
inline

Performs "deterministic" move in 2D.

Parameters
ac_The action to be performed.
Returns
True if move was performed, false if it was not possible.

Definition at line 131 of file Position2D.hpp.

References mic::types::Action2DInterface::dx, mic::types::Action2DInterface::dy, x, and y.

bool mic::types::Position2D::move ( Action2DInterface  ac_,
size_t  width_,
size_t  height_,
bool  circular_world_ = true 
)
inline

Performs "deterministic" move in 2D. Depending on the value of circular_world_ flag, exceeding the boundaries will result in moving to the "other side" of the space (if true) or return the information that the move was not possible.

Parameters
ac_The action to be performed.
width_Width of the "2D space".
height_Height of the "2D space".
circular_world_Flag determining whether exceeding the boundaries will result in moving to the "other side" of the space (if true) or return the information that the move was not possible.
Returns
True if move was performed, false if it was not possible.

Definition at line 147 of file Position2D.hpp.

References mic::types::Action2DInterface::dx, mic::types::Action2DInterface::dy, x, and y.

mic::types::Position2D mic::types::Position2D::operator+ ( Action2DInterface  ac_)
inline

Operator returning new position being the result of the taken action from given position.

Parameters
ac_The action to be performed.
Returns
New, resulting position.

Definition at line 106 of file Position2D.hpp.

References mic::types::Action2DInterface::dx, mic::types::Action2DInterface::dy, x, and y.

bool mic::types::Position2D::operator== ( mic::types::Position2D  pos_)
inline

Comparison operator.

Parameters
pos_The compared position.
Returns
True if positions are "equal".

Definition at line 118 of file Position2D.hpp.

References x, and y.

void mic::types::Position2D::rand ( size_t  min_x_,
size_t  max_x_,
size_t  min_y_,
size_t  max_y_ 
)
inline

Random position.

Parameters
min_x_Min x cooridnate.
max_x_Max x cooridnate.
min_y_Min y cooridnate.
max_y_Max y cooridnate.

Definition at line 72 of file Position2D.hpp.

References x, and y.

Referenced by Position2D().

void mic::types::Position2D::set ( long  x_,
long  y_ 
)
inline

Sets position coordinates.

Parameters
x_The x coordinate.
y_The y coordinate.

Definition at line 96 of file Position2D.hpp.

References x, and y.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os_,
const Position2D pos_ 
)
friend

Returns ostream containing description of given position.

Parameters
os_Ostream.
pos_Position.
Returns
Returned ostream object.

Definition at line 174 of file Position2D.hpp.

Member Data Documentation

long mic::types::Position2D::x

The x coordinate.

Definition at line 39 of file Position2D.hpp.

Referenced by move(), operator+(), operator==(), rand(), and set().

long mic::types::Position2D::y

The y coordinate.

Definition at line 42 of file Position2D.hpp.

Referenced by move(), operator+(), operator==(), rand(), and set().


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