Position Class Reference
[Spaces]

Represents (x,y) in R^2. More...

#include <R2.h>

List of all members.

Public Member Functions

 Position ()
 Default constructor.
 Position (const Decimal &x_in, const Decimal &y_in)
 x y constructor.
 Position (const Angle &theta)
 Angle constructor (gives sin() and cos() of theta).
 Position (const Decimal &d, const Angle &theta)
 Distance angle constructor (gives d*sin(theta) and d*cos(theta)).
 Position (const Position &p)
 Copy constructor.
void setX (const Decimal &x)
 Sets x coordinate.
void setY (const Decimal &y)
 Sets y coordinate.
Positionoperator= (const Position &rhs)
 Assigment operator =.
Positionoperator+= (const Position &a)
 Compound assignment operator +=.
Positionoperator-= (const Position &a)
 Compound assignment operator -=.
Positionoperator*= (const Decimal &scalar)
 Compound assignment operator product by a scalar *=.
Positionoperator/= (const Decimal &scalar)
 Compound assignment operator division by a scalar /=.
Positionoperator+= (const Decimal &scalar)
 Compound assignment operator sum by a scalar.
Positionoperator+= (const Angle &angle)
 Compound assignment operator sum by a Angle.
Positionoperator-= (const Decimal &scalar)
 Compound assignment operator sub by a scalar.
Positionoperator-= (const Angle &angle)
 Compound assignment operator sub by a Angle.
Position operator+ (const Decimal &other) const
 Binary arithmetic operator +.
Position operator- (const Decimal &other) const
 Binary arithmetic operator -.
Position operator+ (const Angle &other) const
 Binary arithmetic operator +.
Position operator- (const Angle &other) const
 Binary arithmetic operator -.
Position operator+ (const Position &other) const
 Binary arithmetic operator +.
Position operator- (const Position &other) const
 Binary arithmetic operator -.
Position operator* (const Decimal &scalar) const
 binary arithmetic operator product by a scalar
Position operator/ (const Decimal &scalar) const
 binary arithmetic operator division by a scalar
bool operator== (const Position &other) const
 compound operator == */
bool operator!= (const Position &other) const
 compound operator != */
Position minimum (const Position &p) const
 minimum with another position
Position maximum (const Position &p) const
 maximum with another position
Decimal x () const
 x coordinate
Decimal y () const
 y coordinate
Decimal norm () const
 Norm of the vector.
Decimal squareNorm () const
 Gets the square of the norm of the vector.
Decimal dist (const Position &p) const
 Distance between two vectors.
Angle bearing () const
 Anomaly in polar coordinates.
Decimal bearingInv () const
 Anomaly in polar coordinates.
Decimal scalar (const Position &p) const
 Scalar product.
vector< Decimalvectorize () const
 Create a 2-compnents vector from the Position.
string print (int precision=4) const
 print
bool fromString (const string &s)
string toString () const

Protected Attributes

Decimal _x
Decimal _y


Detailed Description

Represents (x,y) in R^2.

Author:
Antonio Franchi
Examples:

exampleDraWin.cpp.


Constructor & Destructor Documentation

Position::Position (  ) 

Default constructor.

Creates a Position with x=0.0, y=0.0.

Position::Position ( const Decimal x_in,
const Decimal y_in 
)

x y constructor.

Parameters:
&x_in Given value for the x coordinate.
&y_in Given value for the y coordinate. Creates a Position with the specified values.

Position::Position ( const Angle theta  ) 

Angle constructor (gives sin() and cos() of theta).

Parameters:
&theta Given value for the angle. Creates a unitary Position vector with the specified angle, as [sin(theta), cos(theta)].

Position::Position ( const Decimal d,
const Angle theta 
)

Distance angle constructor (gives d*sin(theta) and d*cos(theta)).

Parameters:
&d Given value for the distance.
&theta Given value for the angle. Creates a Position vector with the specified distance and angle, as [d*sin(theta), d*cos(theta)].

Position::Position ( const Position p  ) 

Copy constructor.

Parameters:
&d Position to be copied.


Member Function Documentation

void Position::setX ( const Decimal x  ) 

Sets x coordinate.

Parameters:
&x Value to be set.

void Position::setY ( const Decimal y  ) 

Sets y coordinate.

Parameters:
&y Value to be set.

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

Assigment operator =.

Parameters:
&rhs Position to be set.

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

Compound assignment operator +=.

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

Compound assignment operator -=.

Position & Position::operator*= ( const Decimal scalar  ) 

Compound assignment operator product by a scalar *=.

Position & Position::operator/= ( const Decimal scalar  ) 

Compound assignment operator division by a scalar /=.

Position & Position::operator+= ( const Decimal scalar  ) 

Compound assignment operator sum by a scalar.

Position & Position::operator+= ( const Angle angle  ) 

Compound assignment operator sum by a Angle.

Rotate the Position by a given Angle counterclockwise.

Position & Position::operator-= ( const Decimal scalar  ) 

Compound assignment operator sub by a scalar.

Position & Position::operator-= ( const Angle angle  ) 

Compound assignment operator sub by a Angle.

Rotate the Position by a given Angle clockwise.

Position Position::operator+ ( const Decimal other  )  const

Binary arithmetic operator +.

Position Position::operator- ( const Decimal other  )  const

Binary arithmetic operator -.

Position Position::operator+ ( const Angle other  )  const

Binary arithmetic operator +.

Position Position::operator- ( const Angle other  )  const

Binary arithmetic operator -.

Position Position::operator+ ( const Position other  )  const

Binary arithmetic operator +.

Position Position::operator- ( const Position other  )  const

Binary arithmetic operator -.

Position Position::operator* ( const Decimal scalar  )  const

binary arithmetic operator product by a scalar

Note:
the scalar must be on the right side of the product

Position Position::operator/ ( const Decimal scalar  )  const

binary arithmetic operator division by a scalar

Note:
the scalar must be on the right side of the product

bool Position::operator== ( const Position other  )  const

compound operator == */

bool Position::operator!= ( const Position other  )  const

compound operator != */

Position Position::minimum ( const Position p  )  const

minimum with another position

Position Position::maximum ( const Position p  )  const

maximum with another position

Decimal Position::x ( void   )  const

x coordinate

Decimal Position::y ( void   )  const

y coordinate

Decimal Position::norm (  )  const

Norm of the vector.

Returns:
the norm of the position vector

Decimal Position::squareNorm (  )  const

Gets the square of the norm of the vector.

Returns:
The square norm of the position vector

Decimal Position::dist ( const Position p  )  const

Distance between two vectors.

Parameters:
p Position in respect to which compute the distance
Returns:
the norm of the difference between "this" and another passed Position

Angle Position::bearing (  )  const

Anomaly in polar coordinates.

Returns:
the bearing (phase or anomaly) of the position vector

Decimal Position::bearingInv (  )  const

Anomaly in polar coordinates.

Returns:
the bearing (phase or anomaly) of the position vector

Decimal Position::scalar ( const Position p  )  const

Scalar product.

Returns:
The scalar product between *this and the input Position
Parameters:
[in] p The other position.

vector< Decimal > Position::vectorize (  )  const

Create a 2-compnents vector from the Position.

Returns:
A vector containing the Position.

string Position::print ( int  precision = 4  )  const

print

bool Position::fromString ( const string &  s  ) 

string Position::toString (  )  const


Member Data Documentation

Decimal Position::_x [protected]

Decimal Position::_y [protected]


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

Generated on Mon Feb 20 07:01:10 2017 for MIP by  doxygen 1.5.6