14 class CRotationMatrix3;
17 #include <argos3/core/utility/math/general.h>
18 #include <argos3/core/utility/math/angles.h>
19 #include <argos3/core/utility/math/vector2.h>
20 #include <argos3/core/utility/string_utilities.h>
161 Real fInclinationSin, fInclinationCos;
162 Real fAzimuthSin, fAzimuthCos;
164 SinCos(c_inclination, fInclinationSin, fInclinationCos);
165 SinCos(c_azimuth, fAzimuthSin, fAzimuthCos);
167 fInclinationSin =
Sin(c_inclination);
168 fInclinationCos =
Cos(c_inclination);
169 fAzimuthSin =
Sin(c_azimuth);
170 fAzimuthCos =
Cos(c_azimuth);
172 m_fX = f_length * fInclinationSin * fAzimuthCos;
173 m_fY = f_length * fInclinationSin * fAzimuthSin;
174 m_fZ = f_length * fInclinationCos;
189 c_inclination =
ACos(m_fZ / f_radius);
190 c_azimuth =
ATan2(m_fY, m_fX);
228 SinCos(c_angle, fSin, fCos);
233 Real fNewY = m_fY * fCos - m_fZ * fSin;
234 Real fNewZ = m_fY * fSin + m_fZ * fCos;
248 SinCos(c_angle, fSin, fCos);
253 Real fNewX = m_fX * fCos + m_fZ * fSin;
254 Real fNewZ = m_fZ * fCos - m_fX * fSin;
268 SinCos(c_angle, fSin, fCos);
273 Real fNewX = m_fX * fCos - m_fY * fSin;
274 Real fNewY = m_fX * fSin + m_fY * fCos;
293 Real fNewX = m_fX * c_vector.
GetX() - m_fY * c_vector.
GetY();
294 Real fNewY = m_fX * c_vector.
GetY() + m_fY * c_vector.
GetX();
324 return ATan2(m_fZ, m_fY);
332 return ATan2(m_fX, m_fZ);
340 return ATan2(m_fY, m_fX);
350 m_fX * c_vector3.m_fX +
351 m_fY * c_vector3.m_fY +
352 m_fZ * c_vector3.m_fZ;
362 Real fNewX, fNewY, fNewZ;
363 fNewX = m_fY * c_vector3.m_fZ - m_fZ * c_vector3.m_fY;
364 fNewY = m_fZ * c_vector3.m_fX - m_fX * c_vector3.m_fZ;
365 fNewZ = m_fX * c_vector3.m_fY - m_fY * c_vector3.m_fX;
378 c_proj.
Set(m_fX,m_fY);
388 c_proj.
Set(m_fY,m_fZ);
398 c_proj.
Set(m_fX,m_fZ);
426 default:
THROW_ARGOSEXCEPTION(
"Real Vector3::operator[]: index " << un_index <<
" out of bounds");
442 default:
THROW_ARGOSEXCEPTION(
"Real Vector3::operator[]: index " << un_index <<
" out of bounds");
453 return m_fX == c_vector3.m_fX && m_fY == c_vector3.m_fY && m_fZ == c_vector3.m_fZ;
463 return !((*this) == c_vector3);
474 return m_fX < c_vector3.m_fX && m_fY < c_vector3.m_fY && m_fZ < c_vector3.m_fZ;
485 return m_fX <= c_vector3.m_fX && m_fY <= c_vector3.m_fY && m_fZ <= c_vector3.m_fZ;
496 return m_fX > c_vector3.m_fX && m_fY > c_vector3.m_fY && m_fZ > c_vector3.m_fZ;
507 return m_fX >= c_vector3.m_fX && m_fY >= c_vector3.m_fY && m_fZ >= c_vector3.m_fZ;
515 return CVector3(-m_fX, -m_fY, -m_fZ);
524 m_fX += c_vector3.m_fX;
525 m_fY += c_vector3.m_fY;
526 m_fZ += c_vector3.m_fZ;
536 m_fX -= c_vector3.m_fX;
537 m_fY -= c_vector3.m_fY;
538 m_fZ -= c_vector3.m_fZ;
573 cResult += c_vector3;
584 cResult -= c_vector3;
618 return c_vector3 * f_value;
629 c_os << c_vector3.m_fX <<
","
630 << c_vector3.m_fY <<
","
644 ParseValues<Real>(c_is, 3, fValues,
',');
645 c_vector3.
Set(fValues[0], fValues[1], fValues[2]);
675 return (c_v1 - c_v2).SquareLength();
685 return (c_v1 - c_v2).Length();
Real Distance(const CVector2 &c_v1, const CVector2 &c_v2)
Computes the distance between the passed vectors.
T Square(const T &t_v)
Returns the square of the value of the passed argument.
CVector3 operator/(const Real f_value) const
Returns a new vector containing the division between this vector and the passed value.
CVector3 operator-() const
Returns a negated copy of this vector.
CVector2 & ProjectOntoXY(CVector2 &c_proj) const
Calculates the projection of this vector onto the xy plane.
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.
friend CVector3 operator*(Real f_value, const CVector3 &c_vector3)
Returns a new vector containing the multiplication between the passed value and the passed vector...
static const CVector3 X
The x axis.
float Real
Collects all ARGoS code.
CRadians ATan2(const Real f_y, const Real f_x)
Computes the arctangent of the passed values.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Real GetX() const
Returns the x coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
bool operator>=(const CVector3 &c_vector3) const
Returns true if this vector is greater than or equal to the passed one.
CVector3 & RotateZ(const CVector2 &c_vector)
Rotates this vector wrt the z axis.
Real GetY() const
Returns the y coordinate of this vector.
CVector3 & FromSphericalCoords(Real f_length, const CRadians &c_inclination, const CRadians &c_azimuth)
Sets the vector contents from spherical coordinates.
Real SquareLength() const
Returns the square length of this vector.
Real Cos(const CRadians &c_radians)
Computes the cosine of the passed value in radians.
friend std::ostream & operator<<(std::ostream &c_os, const CVector3 &c_vector3)
Serializes the contents of the passed vector onto a stream.
void ToSphericalCoords(Real &f_radius, CRadians &c_inclination, CRadians &c_azimuth) const
Returns the vector contents as spherical coordinates.
Real GetY() const
Returns the y coordinate of this vector.
CRadians GetXAngle() const
Returns the angle between this vector and the x axis.
bool operator<(const CVector3 &c_vector3) const
Returns true if this vector is smaller than the passed one.
CVector3 & operator-=(const CVector3 &c_vector3)
Subtracts the passed vector from this vector.
CVector3 & operator/=(Real f_value)
Divides this vector by the given value.
It defines the basic type CRadians, used to store an angle value in radians.
CVector3(Real f_length, const CRadians &c_inclination, const CRadians &c_azimuth)
Class constructor.
Real Length() const
Returns the length of this vector.
CVector2 & ProjectOntoXZ(CVector2 &c_proj) const
Calculates the projection of this vector onto the xz plane.
unsigned int UInt32
32-bit unsigned integer.
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
CVector3 & operator*=(Real f_value)
Multiplies this vector by the given value.
void SetX(const Real f_x)
Sets the x coordinate of this vector.
Real Sin(const CRadians &c_radians)
Computes the sine of the passed value in radians.
CVector3 operator+(const CVector3 &c_vector3) const
Returns a new vector containing the sum between this vector and the passed one.
Real SquareDistance(const CVector2 &c_v1, const CVector2 &c_v2)
Computes the square distance between the passed vectors.
CVector3 & operator+=(const CVector3 &c_vector3)
Sums the passed vector to this vector.
CVector3 & RotateX(const CRadians &c_angle)
Rotates this vector wrt the x axis.
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 not equal.
CVector3(Real f_x, Real f_y, Real f_z)
Class constructor.
static const CVector3 ZERO
The zero vector (0,0,0)
void SinCos(const CRadians &c_radians, Real &f_sin, Real &f_cos)
Computes the sine and cosine of the passed value in radians.
static const CVector3 Z
The z axis.
static const CVector3 Y
The y axis.
void SetY(const Real f_y)
Sets the y coordinate of this vector.
Real DotProduct(const CVector3 &c_vector3) const
Returns the dot product between this vector and the passed one.
CRadians GetAngleWith(const CVector3 &c_other)
Returns the angle between this vector and the passed vector.
CVector3()
Class constructor.
friend std::istream & operator>>(std::istream &c_is, CVector3 &c_vector3)
Deserializes the contents of a stream and stores them into the passed vector.
CVector3 & CrossProduct(const CVector3 &c_vector3)
Calculates the cross product between this vector and the passed one.
CRadians GetYAngle() const
Returns the angle between this vector and the y axis.
bool operator>(const CVector3 &c_vector3) const
Returns true if this vector is greater than the passed one.
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
The namespace containing all the ARGoS related code.
Real GetZ() const
Returns the z coordinate of this vector.
void SetZ(const Real f_z)
Sets the z coordinate of this vector.
CRadians ACos(Real f_value)
Computes the arccosine of the passed value.
CVector3 & Negate()
Negates this vector.
CVector3 & Normalize()
Normalizes this vector.
CVector3 operator*(Real f_value) const
Returns a new vector containing the multiplication between this vector and the passed value...
bool operator<=(const CVector3 &c_vector3) const
Returns true if this vector is smaller than or equal to the passed one.
Real operator[](UInt32 un_index) const
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.
CVector3 operator-(const CVector3 &c_vector3) const
Returns a new vector containing the subtraction between this vector and the passed one...
CRadians GetZAngle() const
Returns the angle between this vector and the z axis.
CVector2 & ProjectOntoYZ(CVector2 &c_proj) const
Calculates the projection of this vector onto the yz plane.