ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
11 class CRotationMatrix2;
14 #include <argos3/core/utility/math/general.h>
15 #include <argos3/core/utility/math/angles.h>
16 #include <argos3/core/utility/string_utilities.h>
70 m_fX(
Cos(f_angle) * f_length),
71 m_fY(
Sin(f_angle) * f_length) {
125 m_fX =
Cos(f_angle) * f_length;
126 m_fY =
Sin(f_angle) * f_length;
161 return ATan2(m_fY, m_fX);
172 SinCos(c_angle, fSin, fCos);
177 Real fX = m_fX * fCos - m_fY * fSin;
178 Real fY = m_fX * fSin + m_fY * fCos;
190 return m_fX * c_vector2.m_fX + m_fY * c_vector2.m_fY;
199 return m_fX * c_vector2.m_fY + m_fY * c_vector2.m_fX;
246 return (m_fX == c_vector2.m_fX && m_fY == c_vector2.m_fY);
256 return (m_fX != c_vector2.m_fX || m_fY != c_vector2.m_fY);
265 m_fX += c_vector2.m_fX;
266 m_fY += c_vector2.m_fY;
276 m_fX -= c_vector2.m_fX;
277 m_fY -= c_vector2.m_fY;
310 cResult += c_vector2;
321 cResult -= c_vector2;
355 return c_vector2 * f_value;
370 c_os << c_vector2.m_fX <<
","
384 ParseValues<Real> (c_is, 2, fValues,
',');
385 c_vector2.
Set(fValues[0], fValues[1]);
409 return (c_v1 - c_v2).SquareLength();
419 return (c_v1 - c_v2).Length();
static const CVector2 Y
The y axis.
CVector2 & Normalize()
Normalizes this vector.
void SetY(Real f_y)
Sets the y coordinate of this vector.
CVector2 operator-() const
CVector2 & operator+=(const CVector2 &c_vector2)
Sums the passed vector to this vector.
Real Cos(const CRadians &c_radians)
Computes the cosine of the passed value in radians.
Real CrossProduct(const CVector2 &c_vector2) const
Returns the cross product between this vector and the passed one.
The namespace containing all the ARGoS related code.
It defines the basic type CRadians, used to store an angle value in radians.
void SinCos(const CRadians &c_radians, Real &f_sin, Real &f_cos)
Computes the sine and cosine of the passed value in radians.
void SetX(Real f_x)
Sets the x coordinate of this vector.
CVector2 & operator*=(Real f_value)
Multiplies this vector by the given value.
Real Sin(const CRadians &c_radians)
Computes the sine of the passed value in radians.
void FromPolarCoordinates(Real f_length, const CRadians &f_angle)
Sets the vector contents from polar coordinates.
CRadians ATan2(const Real f_y, const Real f_x)
Computes the arctangent of the passed values.
CRadians Angle() const
Returns the angle of this vector.
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
Real GetY() const
Returns the y coordinate of this vector.
Real Distance(const CVector2 &c_v1, const CVector2 &c_v2)
Computes the distance between the passed vectors.
CVector2 & Absolute()
Applies Abs() to the coordinates of this vector.
CVector2 operator-(const CVector2 &c_vector2) const
Returns a new vector containing the subtraction between this vector and the passed one.
friend CVector2 operator*(Real f_value, const CVector2 &c_vector2)
Returns a new vector containing the multiplication between the passed value and the passed vector.
T Abs(const T &t_v)
Returns the absolute value of the passed argument.
CVector2(Real f_x, Real f_y)
Class constructor.
bool operator==(const CVector2 &c_vector2) const
Returns true if this vector and the passed one are equal.
static const CVector2 X
The x axis.
CVector2()
Class constructor.
Real GetX() const
Returns the x coordinate of this vector.
Real DotProduct(const CVector2 &c_vector2) const
Returns the dot product between this vector and the passed one.
friend std::istream & operator>>(std::istream &c_is, CVector2 &c_vector2)
Deserializes the contents of a stream and stores them into the passed vector.
friend std::ostream & operator<<(std::ostream &c_os, const CVector2 &c_vector2)
Serializes the contents of the passed vector onto a stream.
Real SquareDistance(const CVector2 &c_v1, const CVector2 &c_v2)
Computes the square distance between the passed vectors.
CVector2 operator/(Real f_value) const
Returns a new vector containing the division between this vector and the passed value.
Real Length() const
Returns the length of this vector.
T Square(const T &t_v)
Returns the square of the value of the passed argument.
CVector2 & operator/=(Real f_value)
Divides this vector by the given value.
CVector2 & Perpendicularize()
Transforms this vector into its ortogonal.
CVector2 operator*(Real f_value) const
Returns a new vector containing the multiplication between this vector and the passed value.
CVector2 & Rotate(const CRadians &c_angle)
Rotates this vector by the wanted angle.
Real SquareLength() const
Returns the square length of this vector.
CVector2 & Scale(Real f_scale_x, Real f_scale_y)
Scales the vector by the wanted values.
float Real
Collects all ARGoS code.
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)
Subtracts the passed vector from this vector.
CVector2(Real f_length, const CRadians &f_angle)
Class constructor.
bool operator!=(const CVector2 &c_vector2) const
Returns true if this vector and the passed one are not equal.