ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CVector2 Class Reference

A 2D vector class. More...

#include <vector2.h>

List of all members.

Public Member Functions

 CVector2 ()
 Class constructor.
 CVector2 (Real f_x, Real f_y)
 Class constructor.
 CVector2 (Real f_length, const CRadians &f_angle)
 Class constructor.
Real GetX () const
 Returns the x coordinate of this vector.
void SetX (Real f_x)
 Sets the x coordinate of this vector.
Real GetY () const
 Returns the y coordinate of this vector.
void SetY (Real f_y)
 Sets the y coordinate of this vector.
void Set (Real f_x, Real f_y)
 Sets the vector contents from Cartesian coordinates.
void FromPolarCoordinates (Real f_length, const CRadians &f_angle)
 Sets the vector contents from polar coordinates.
Real SquareLength () const
 Returns the square length of this vector.
Real Length () const
 Returns the length of this vector.
CVector2Normalize ()
 Normalizes this vector.
CRadians Angle () const
 Returns the angle of this vector.
CVector2Rotate (const CRadians &c_angle)
 Rotates this vector by the wanted angle.
Real DotProduct (const CVector2 &c_vector2) const
 Returns the dot product between this vector and the passed one.
CVector2Scale (Real f_scale_x, Real f_scale_y)
 Scales the vector by the wanted values.
CVector2Perpendicularize ()
 Transforms this vector into its ortogonal.
CVector2Absolute ()
 Applies Abs() to the coordinates of this vector.
bool operator== (const CVector2 &c_vector2)
 Returns true if this vector and the passed one are equal.
bool operator!= (const CVector2 &c_vector2)
 Returns true if this vector and the passed one are not equal.
CVector2operator+= (const CVector2 &c_vector2)
 Sums the passed vector to this vector.
CVector2operator-= (const CVector2 &c_vector2)
 Subtracts the passed vector from this vector.
CVector2operator*= (Real f_value)
 Multiplies this vector by the given value.
CVector2operator/= (Real f_value)
 Divides this vector by the given value.
CVector2 operator+ (const CVector2 &c_vector2) const
 Returns a new vector containing the sum between this vector and the passed one.
CVector2 operator- (const CVector2 &c_vector2) const
 Returns a new vector containing the subtraction between this vector and the passed one.
CVector2 operator* (Real f_value) const
 Returns a new vector containing the multiplication between this vector and the passed value.
CVector2 operator/ (Real f_value) const
 Returns a new vector containing the division between this vector and the passed value.
CVector2 operator- () const

Static Public Attributes

static const CVector2 X
 The x axis.
static const CVector2 Y
 The y axis.

Friends

class CRotationMatrix2
class CTransformationMatrix2
CVector2 operator* (Real f_value, const CVector2 &c_vector2)
 Returns a new vector containing the multiplication between the passed value and the passed vector.
std::ostream & operator<< (std::ostream &c_os, const CVector2 &c_vector2)
 Serializes the contents of the passed vector onto a stream.
std::istream & operator>> (std::istream &c_is, CVector2 &c_vector2)
 Deserializes the contents of a stream and stores them into the passed vector.

Detailed Description

A 2D vector class.

Definition at line 25 of file vector2.h.


Constructor & Destructor Documentation

Class constructor.

It initializes the vector to (0,0).

See also:
ZERO

Definition at line 43 of file vector2.h.

argos::CVector2::CVector2 ( Real  f_x,
Real  f_y 
) [inline]

Class constructor.

It initializes the vector from Cartesian coordinates.

Parameters:
f_xThe x coordinate.
f_yThe y coordinate.
See also:
Set()

Definition at line 55 of file vector2.h.

argos::CVector2::CVector2 ( Real  f_length,
const CRadians f_angle 
) [inline]

Class constructor.

It initializes the vector coordinates from polar coordinates.

Parameters:
f_lengththe vector length.
f_anglethe vector angle.
See also:
FromPolarCoordinates()

Definition at line 68 of file vector2.h.


Member Function Documentation

Applies Abs() to the coordinates of this vector.

Returns:
A reference to this vector.

Definition at line 224 of file vector2.h.

CRadians argos::CVector2::Angle ( ) const [inline]

Returns the angle of this vector.

Returns:
the angle of this vector.

Definition at line 160 of file vector2.h.

Real argos::CVector2::DotProduct ( const CVector2 c_vector2) const [inline]

Returns the dot product between this vector and the passed one.

Parameters:
c_vector3The other vector.
Returns:
The dot product between this vector and the passed one.

Definition at line 189 of file vector2.h.

void argos::CVector2::FromPolarCoordinates ( Real  f_length,
const CRadians f_angle 
) [inline]

Sets the vector contents from polar coordinates.

Parameters:
f_lengthThe length of the vector.
c_angleThe angle of the vector (range [0,2pi])
See also:
Length()
Angle()

Definition at line 123 of file vector2.h.

Real argos::CVector2::GetX ( ) const [inline]

Returns the x coordinate of this vector.

Returns:
The x coordinate of this vector.

Definition at line 78 of file vector2.h.

Real argos::CVector2::GetY ( ) const [inline]

Returns the y coordinate of this vector.

Returns:
The y coordinate of this vector.

Definition at line 94 of file vector2.h.

Real argos::CVector2::Length ( ) const [inline]

Returns the length of this vector.

Returns:
The length of this vector.

Definition at line 141 of file vector2.h.

Normalizes this vector.

After this method is called, the vector has length 1. If the vector is (0,0), this call results in a division by zero error.

Returns:
A reference to this vector.

Definition at line 151 of file vector2.h.

bool argos::CVector2::operator!= ( const CVector2 c_vector2) [inline]

Returns true if this vector and the passed one are not equal.

This method checks all the coordinates for equality.

Parameters:
c_vector2The other vector.
Returns:
true if this vector and the passed one are not equal.

Definition at line 246 of file vector2.h.

CVector2 argos::CVector2::operator* ( Real  f_value) const [inline]

Returns a new vector containing the multiplication between this vector and the passed value.

Parameters:
f_valueThe wanted value.
Returns:
A new vector containing the multiplication between this vector and the passed value.

Definition at line 321 of file vector2.h.

CVector2& argos::CVector2::operator*= ( Real  f_value) [inline]

Multiplies this vector by the given value.

Parameters:
f_valueThe wanted value.
Returns:
A reference to this vector.

Definition at line 277 of file vector2.h.

CVector2 argos::CVector2::operator+ ( const CVector2 c_vector2) const [inline]

Returns a new vector containing the sum between this vector and the passed one.

Parameters:
c_vector2The other vector.
Returns:
A new vector containing the sum between this vector and the passed one.

Definition at line 299 of file vector2.h.

CVector2& argos::CVector2::operator+= ( const CVector2 c_vector2) [inline]

Sums the passed vector to this vector.

Parameters:
c_vector2The other vector.
Returns:
A reference to this vector.

Definition at line 255 of file vector2.h.

CVector2 argos::CVector2::operator- ( const CVector2 c_vector2) const [inline]

Returns a new vector containing the subtraction between this vector and the passed one.

Parameters:
c_vector2The other vector.
Returns:
A new vector containing the subtraction between this vector and the passed one.

Definition at line 310 of file vector2.h.

CVector2 argos::CVector2::operator- ( ) const [inline]

Definition at line 349 of file vector2.h.

CVector2& argos::CVector2::operator-= ( const CVector2 c_vector2) [inline]

Subtracts the passed vector from this vector.

Parameters:
c_vector3The other vector.
Returns:
A reference to this vector.

Definition at line 266 of file vector2.h.

CVector2 argos::CVector2::operator/ ( Real  f_value) const [inline]

Returns a new vector containing the division between this vector and the passed value.

Parameters:
f_valueThe wanted value.
Returns:
A new vector containing the division between this vector and the passed value.

Definition at line 332 of file vector2.h.

CVector2& argos::CVector2::operator/= ( Real  f_value) [inline]

Divides this vector by the given value.

Parameters:
f_valueThe wanted value.
Returns:
A reference to this vector.

Definition at line 288 of file vector2.h.

bool argos::CVector2::operator== ( const CVector2 c_vector2) [inline]

Returns true if this vector and the passed one are equal.

This method checks all the coordinates for equality.

Parameters:
c_vector2The other vector.
Returns:
true if this vector and the passed one are equal.

Definition at line 236 of file vector2.h.

Transforms this vector into its ortogonal.

Returns:
A reference to this vector.

Definition at line 213 of file vector2.h.

CVector2& argos::CVector2::Rotate ( const CRadians c_angle) [inline]

Rotates this vector by the wanted angle.

Parameters:
c_angleThe rotation angle.
Returns:
A reference to this vector.

Definition at line 169 of file vector2.h.

CVector2& argos::CVector2::Scale ( Real  f_scale_x,
Real  f_scale_y 
) [inline]

Scales the vector by the wanted values.

This method scales the vector by the wanted values. In practice, this means that it multiplies the x coordinate by f_scale_x and the y coordinate by f_scale_y.

Parameters:
f_scale_xthe scale factor for the x coordinate.
f_scale_ythe scale factor for the y coordinate.
Returns:
A reference to this vector.

Definition at line 202 of file vector2.h.

void argos::CVector2::Set ( Real  f_x,
Real  f_y 
) [inline]

Sets the vector contents from Cartesian coordinates.

Parameters:
f_xThe new x coordinate of this vector.
f_yThe new y coordinate of this vector.

Definition at line 111 of file vector2.h.

void argos::CVector2::SetX ( Real  f_x) [inline]

Sets the x coordinate of this vector.

Parameters:
f_xThe new x coordinate of this vector.

Definition at line 86 of file vector2.h.

void argos::CVector2::SetY ( Real  f_y) [inline]

Sets the y coordinate of this vector.

Parameters:
f_yThe new y coordinate of this vector.

Definition at line 102 of file vector2.h.

Real argos::CVector2::SquareLength ( ) const [inline]

Returns the square length of this vector.

Returns:
The square length of this vector.

Definition at line 133 of file vector2.h.


Friends And Related Function Documentation

friend class CRotationMatrix2 [friend]

Definition at line 27 of file vector2.h.

friend class CTransformationMatrix2 [friend]

Definition at line 28 of file vector2.h.

CVector2 operator* ( Real  f_value,
const CVector2 c_vector2 
) [friend]

Returns a new vector containing the multiplication between the passed value and the passed vector.

Parameters:
f_valueThe value.
c_vector3The vector.
Returns:
A new vector containing the multiplication between the passed value and the passed vector.

Definition at line 344 of file vector2.h.

std::ostream& operator<< ( std::ostream &  c_os,
const CVector2 c_vector2 
) [friend]

Serializes the contents of the passed vector onto a stream.

Parameters:
c_osThe stream.
c_vector2The vector.
Returns:
The new state of the stream.

Definition at line 359 of file vector2.h.

std::istream& operator>> ( std::istream &  c_is,
CVector2 c_vector2 
) [friend]

Deserializes the contents of a stream and stores them into the passed vector.

Parameters:
c_isThe stream.
c_vector2The vector.
Returns:
The new state of the stream.

Definition at line 372 of file vector2.h.


Member Data Documentation

const CVector2 argos::CVector2::X [static]

The x axis.

Definition at line 33 of file vector2.h.

const CVector2 argos::CVector2::Y [static]

The y axis.

Definition at line 36 of file vector2.h.


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