18 #ifndef _GAZEBO_MATH_QUATERNION_HH_
19 #define _GAZEBO_MATH_QUATERNION_HH_
24 #include <ignition/math/Quaternion.hh>
52 public:
Quaternion(
const double &_w,
const double &_x,
const double &_y,
59 public:
Quaternion(
const double &_roll,
const double &_pitch,
77 public:
Quaternion(
const ignition::math::Quaterniond &_qt);
88 public: ignition::math::Quaterniond Ign()
const;
93 public:
Quaternion &operator =(
const ignition::math::Quaterniond &_v);
96 public:
void Invert();
103 Quaternion q(this->w, this->x, this->y, this->z);
106 s = q.
w * q.
w + q.
x * q.
x + q.
y * q.
y + q.
z * q.
z;
128 public:
void SetToIdentity();
139 public:
void Normalize();
146 public:
void SetFromAxis(
double _x,
double _y,
double _z,
double _a);
151 public:
void SetFromAxis(
const Vector3 &_axis,
double _a);
158 public:
void Set(
double _u,
double _x,
double _y,
double _z);
165 public:
void SetFromEuler(
const Vector3 &_vec);
171 public:
void SetFromEuler(
double _roll,
double _pitch,
double _yaw);
175 public:
Vector3 GetAsEuler()
const;
187 public:
static Quaternion EulerToQuaternion(
double _x,
193 public:
double GetRoll();
197 public:
double GetPitch();
201 public:
double GetYaw();
206 public:
void GetAsAxis(
Vector3 &_axis,
double &_angle)
const;
210 public:
void Scale(
double _scale);
238 this->w*_q.
w - this->x*_q.
x - this->y*_q.
y - this->z*_q.
z,
239 this->w*_q.
x + this->x*_q.
w + this->y*_q.
z - this->z*_q.
y,
240 this->w*_q.
y - this->x*_q.
z + this->y*_q.
w + this->z*_q.
x,
241 this->w*_q.
z + this->x*_q.
y - this->y*_q.
x + this->z*_q.
w);
247 public:
Quaternion operator*(
const double &_f)
const;
262 public:
bool operator ==(
const Quaternion &_qt)
const;
267 public:
bool operator!=(
const Quaternion &_qt)
const;
279 tmp = (*this) * (tmp * this->GetInverse());
290 public:
bool IsFinite()
const;
295 if (!std::isfinite(this->x))
297 if (!std::isfinite(this->y))
299 if (!std::isfinite(this->z))
301 if (!std::isfinite(this->w))
315 public:
Matrix3 GetAsMatrix3()
const;
319 public:
Matrix4 GetAsMatrix4()
const;
323 public:
Vector3 GetXAxis()
const;
327 public:
Vector3 GetYAxis()
const;
331 public:
Vector3 GetZAxis()
const;
335 public:
void Round(
int _precision);
340 public:
double Dot(
const Quaternion &_q)
const;
354 const Quaternion &_rkQ,
bool _shortestPath =
false);
365 const Quaternion &_rkQ,
bool _shortestPath =
false);
374 const double _deltaT)
const;
408 Angle roll, pitch, yaw;
411 _in.setf(std::ios_base::skipws);
412 _in >> roll >> pitch >> yaw;
double z
z value of the quaternion
Definition: Quaternion.hh:386
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
A 3x3 matrix class.
Definition: Matrix4.hh:40
double x
X location.
Definition: Vector3.hh:311
Vector3 RotateVector(const Vector3 &_vec) const
Rotate a vector using the quaternion.
Definition: Quaternion.hh:276
void SetFromEuler(const Vector3 &_vec)
Set the quaternion from Euler angles.
double z
Z location.
Definition: Vector3.hh:317
Quaternion operator*(const Quaternion &_q) const
Multiplication operator.
Definition: Quaternion.hh:235
bool equal(const T &_a, const T &_b, const T &_epsilon=1e-6)
check if two values are equal, within a tolerance
Definition: Helpers.hh:171
A 3x3 matrix class.
Definition: Matrix3.hh:34
void Correct()
Correct any nan values in this quaternion.
Definition: Quaternion.hh:293
double w
w value of the quaternion
Definition: Quaternion.hh:377
#define GZ_MATH_VISIBLE
Definition: system.hh:141
A quaternion class.
Definition: Quaternion.hh:42
friend std::istream & operator>>(std::istream &_in, gazebo::math::Quaternion &_q)
Stream extraction operator.
Definition: Quaternion.hh:405
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
double y
y value of the quaternion
Definition: Quaternion.hh:383
Quaternion GetInverse() const
Get the inverse of this quaternion.
Definition: Quaternion.hh:100
double x
x value of the quaternion
Definition: Quaternion.hh:380
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:182
An angle and related functions.
Definition: Angle.hh:53
double y
Y location.
Definition: Vector3.hh:314
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Quaternion &_q)
Stream insertion operator.
Definition: Quaternion.hh:392
Vector3 GetAsEuler() const
Return the rotation in Euler angles.