ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
A 3D vector class. More...
#include <vector3.h>
Public Member Functions | |
CVector3 () | |
Class constructor. | |
CVector3 (Real f_x, Real f_y, Real f_z) | |
Class constructor. | |
CVector3 (Real f_length, const CRadians &c_inclination, const CRadians &c_azimuth) | |
Class constructor. | |
Real | GetX () const |
Returns the x coordinate of this vector. | |
void | SetX (const Real f_x) |
Sets the x coordinate of this vector. | |
Real | GetY () const |
Returns the y coordinate of this vector. | |
void | SetY (const Real f_y) |
Sets the y coordinate of this vector. | |
Real | GetZ () const |
Returns the z coordinate of this vector. | |
void | SetZ (const Real f_z) |
Sets the z coordinate of this vector. | |
void | Set (const Real f_x, const Real f_y, const Real f_z) |
Sets the vector contents from Cartesian coordinates. | |
CVector3 & | FromSphericalCoords (Real f_length, const CRadians &c_inclination, const CRadians &c_azimuth) |
Sets the vector contents from spherical coordinates. | |
void | ToSphericalCoords (Real &f_radius, CRadians &c_inclination, CRadians &c_azimuth) const |
Returns the vector contents as spherical coordinates. | |
Real | SquareLength () const |
Returns the square length of this vector. | |
Real | Length () const |
Returns the length of this vector. | |
CVector3 & | Normalize () |
Normalizes this vector. | |
CVector3 & | RotateX (const CRadians &c_angle) |
Rotates this vector wrt the x axis. | |
CVector3 & | RotateY (const CRadians &c_angle) |
Rotates this vector wrt the y axis. | |
CVector3 & | RotateZ (const CRadians &c_angle) |
Rotates this vector wrt the z axis. | |
CVector3 & | RotateZ (const CVector2 &c_vector) |
Rotates this vector wrt the z axis. | |
CVector3 & | Rotate (const CQuaternion &c_quaternion) |
Rotates this vector by the given quaternion. | |
CRadians | GetAngleWith (const CVector3 &c_other) |
Returns the angle between this vector and the passed vector. | |
CRadians | GetXAngle () const |
Returns the angle between this vector and the x axis. | |
CRadians | GetYAngle () const |
Returns the angle between this vector and the y axis. | |
CRadians | GetZAngle () const |
Returns the angle between this vector and the z axis. | |
Real | DotProduct (const CVector3 &c_vector3) const |
Returns the dot product between this vector and the passed one. | |
CVector3 & | CrossProduct (const CVector3 &c_vector3) |
Calculates the cross product between this vector and the passed one. | |
CVector2 & | ProjectOntoXY (CVector2 &c_proj) const |
Calculates the projection of this vector onto the xy plane. | |
CVector2 & | ProjectOntoYZ (CVector2 &c_proj) const |
Calculates the projection of this vector onto the yz plane. | |
CVector2 & | ProjectOntoXZ (CVector2 &c_proj) const |
Calculates the projection of this vector onto the xz plane. | |
CVector3 & | Negate () |
Negates this vector. | |
Real | operator[] (UInt32 un_index) const |
Returns a Cartesian coordinate of this vector. | |
Real & | operator[] (UInt32 un_index) |
Returns a Cartesian coordinate of this vector. | |
bool | operator== (const CVector3 &c_vector3) const |
Returns true if this vector and the passed one are equal. | |
bool | operator!= (const CVector3 &c_vector3) const |
Returns true if this vector and the passed one are not equal. | |
bool | operator< (const CVector3 &c_vector3) const |
Returns true if this vector is smaller than the passed one. | |
bool | operator<= (const CVector3 &c_vector3) const |
Returns true if this vector is smaller than or equal to the passed one. | |
bool | operator> (const CVector3 &c_vector3) const |
Returns true if this vector is greater than the passed one. | |
bool | operator>= (const CVector3 &c_vector3) const |
Returns true if this vector is greater than or equal to the passed one. | |
CVector3 | operator- () const |
Returns a negated copy of this vector. | |
CVector3 & | operator+= (const CVector3 &c_vector3) |
Sums the passed vector to this vector. | |
CVector3 & | operator-= (const CVector3 &c_vector3) |
Subtracts the passed vector from this vector. | |
CVector3 & | operator*= (Real f_value) |
Multiplies this vector by the given value. | |
CVector3 & | operator/= (Real f_value) |
Divides this vector by the given value. | |
CVector3 | operator+ (const CVector3 &c_vector3) const |
Returns a new vector containing the sum between this vector and the passed one. | |
CVector3 | operator- (const CVector3 &c_vector3) const |
Returns a new vector containing the subtraction between this vector and the passed one. | |
CVector3 | operator* (Real f_value) const |
Returns a new vector containing the multiplication between this vector and the passed value. | |
CVector3 | operator/ (const Real f_value) const |
Returns a new vector containing the division between this vector and the passed value. | |
Static Public Attributes | |
static const CVector3 | X |
The x axis. | |
static const CVector3 | Y |
The y axis. | |
static const CVector3 | Z |
The z axis. | |
static const CVector3 | ZERO |
The zero vector (0,0,0) | |
Friends | |
class | CRotationMatrix3 |
class | CTransformationMatrix3 |
CVector3 | operator* (Real f_value, const CVector3 &c_vector3) |
Returns a new vector containing the multiplication between the passed value and the passed vector. | |
std::ostream & | operator<< (std::ostream &c_os, const CVector3 &c_vector3) |
Serializes the contents of the passed vector onto a stream. | |
std::istream & | operator>> (std::istream &c_is, CVector3 &c_vector3) |
Deserializes the contents of a stream and stores them into the passed vector. |
argos::CVector3::CVector3 | ( | ) | [inline] |
argos::CVector3::CVector3 | ( | Real | f_x, |
Real | f_y, | ||
Real | f_z | ||
) | [inline] |
argos::CVector3::CVector3 | ( | Real | f_length, |
const CRadians & | c_inclination, | ||
const CRadians & | c_azimuth | ||
) | [inline] |
Class constructor.
It initializes the vector from spherical coordinates.
f_length | The length of the vector. |
c_inclination | The angle between the z axis and the vector (range [-pi,pi]) |
c_azimuth | The angle on the xy plane (range [0,2pi]) |
CVector3& argos::CVector3::CrossProduct | ( | const CVector3 & | c_vector3 | ) | [inline] |
Real argos::CVector3::DotProduct | ( | const CVector3 & | c_vector3 | ) | const [inline] |
CVector3& argos::CVector3::FromSphericalCoords | ( | Real | f_length, |
const CRadians & | c_inclination, | ||
const CRadians & | c_azimuth | ||
) | [inline] |
Sets the vector contents from spherical coordinates.
f_length | The length of the vector. |
c_inclination | The angle between the z axis and the vector (range [-pi,pi]) |
c_azimuth | The angle on the xy plane (range [0,2pi]) |
CRadians argos::CVector3::GetAngleWith | ( | const CVector3 & | c_other | ) | [inline] |
Real argos::CVector3::GetX | ( | ) | const [inline] |
CRadians argos::CVector3::GetXAngle | ( | ) | const [inline] |
Real argos::CVector3::GetY | ( | ) | const [inline] |
CRadians argos::CVector3::GetYAngle | ( | ) | const [inline] |
Real argos::CVector3::GetZ | ( | ) | const [inline] |
CRadians argos::CVector3::GetZAngle | ( | ) | const [inline] |
Real argos::CVector3::Length | ( | ) | const [inline] |
CVector3& argos::CVector3::Negate | ( | ) | [inline] |
CVector3& argos::CVector3::Normalize | ( | ) | [inline] |
bool argos::CVector3::operator!= | ( | const CVector3 & | c_vector3 | ) | const [inline] |
CVector3 argos::CVector3::operator- | ( | ) | const [inline] |
bool argos::CVector3::operator< | ( | const CVector3 & | c_vector3 | ) | const [inline] |
Returns true
if this vector is smaller than the passed one.
This method checks all the coordinates, and returns true
only if the condition is true for all of them.
c_vector3 | The other vector. |
true
if this vector is smaller than the passed one. bool argos::CVector3::operator<= | ( | const CVector3 & | c_vector3 | ) | const [inline] |
Returns true
if this vector is smaller than or equal to the passed one.
This method checks all the coordinates, and returns true
only if the condition is true for all of them.
c_vector3 | The other vector. |
true
if this vector is smaller than or equal to the passed one. bool argos::CVector3::operator== | ( | const CVector3 & | c_vector3 | ) | const [inline] |
bool argos::CVector3::operator> | ( | const CVector3 & | c_vector3 | ) | const [inline] |
Returns true
if this vector is greater than the passed one.
This method checks all the coordinates, and returns true
only if the condition is true for all of them.
c_vector3 | The other vector. |
true
if this vector is greater than the passed one. bool argos::CVector3::operator>= | ( | const CVector3 & | c_vector3 | ) | const [inline] |
Returns true
if this vector is greater than or equal to the passed one.
This method checks all the coordinates, and returns true
only if the condition is true for all of them.
c_vector3 | The other vector. |
true
if this vector is greater than or equal to the passed one. Returns a Cartesian coordinate of this vector.
This method returns the value by copy.
un_index | The desired coordinate, with 0 mapping to x, 1 mapping to y, and 2 mapping to z. |
CARGoSException | if the given index is out of bounds. |
Returns a Cartesian coordinate of this vector.
This method returns the value by reference.
un_index | The desired coordinate, with 0 mapping to x, 1 mapping to y, and 2 mapping to z. |
CARGoSException | if the given index is out of bounds. |
CVector2& argos::CVector3::ProjectOntoXY | ( | CVector2 & | c_proj | ) | const [inline] |
CVector2& argos::CVector3::ProjectOntoXZ | ( | CVector2 & | c_proj | ) | const [inline] |
CVector2& argos::CVector3::ProjectOntoYZ | ( | CVector2 & | c_proj | ) | const [inline] |
CVector3 & argos::CVector3::Rotate | ( | const CQuaternion & | c_quaternion | ) |
Rotates this vector by the given quaternion.
c_quaternion | The quaternion to use. |
Definition at line 25 of file vector3.cpp.
CVector3& argos::CVector3::RotateX | ( | const CRadians & | c_angle | ) | [inline] |
CVector3& argos::CVector3::RotateY | ( | const CRadians & | c_angle | ) | [inline] |
CVector3& argos::CVector3::RotateZ | ( | const CRadians & | c_angle | ) | [inline] |
CVector3& argos::CVector3::RotateZ | ( | const CVector2 & | c_vector | ) | [inline] |
Rotates this vector wrt the z axis.
This method rotates the vector wrt to the z axis using a 2d vector that is expected to contain: (cos(angle), sin(angle)). This method is mostly useful when you must rotate a lot of vectors by the same angle. You calculate the angle's cosine and sine, store it, and using multiple times. For speed reasons, no checks are performed - be sure you feed this method the right values.
c_vector | The precalculated cosine and sine of the rotation angle. |
void argos::CVector3::Set | ( | const Real | f_x, |
const Real | f_y, | ||
const Real | f_z | ||
) | [inline] |
void argos::CVector3::SetX | ( | const Real | f_x | ) | [inline] |
void argos::CVector3::SetY | ( | const Real | f_y | ) | [inline] |
void argos::CVector3::SetZ | ( | const Real | f_z | ) | [inline] |
Real argos::CVector3::SquareLength | ( | ) | const [inline] |
void argos::CVector3::ToSphericalCoords | ( | Real & | f_radius, |
CRadians & | c_inclination, | ||
CRadians & | c_azimuth | ||
) | const [inline] |
Returns the vector contents as spherical coordinates.
f_length | A buffer for the length of the vector. |
c_inclination | A buffer for the angle between the z axis and the vector (range [-pi,pi]) |
c_azimuth | A buffer for the angle on the xy plane (range [0,2pi]) |
friend class CRotationMatrix3 [friend] |
friend class CTransformationMatrix3 [friend] |
std::ostream& operator<< | ( | std::ostream & | c_os, |
const CVector3 & | c_vector3 | ||
) | [friend] |
std::istream& operator>> | ( | std::istream & | c_is, |
CVector3 & | c_vector3 | ||
) | [friend] |
const CVector3 argos::CVector3::X [static] |
const CVector3 argos::CVector3::Y [static] |
const CVector3 argos::CVector3::Z [static] |
const CVector3 argos::CVector3::ZERO [static] |