18 #ifndef _GAZEBO_MATH_QUATERNION_HH_
19 #define _GAZEBO_MATH_QUATERNION_HH_
51 public:
Quaternion(
const double &_w,
const double &_x,
const double &_y,
58 public:
Quaternion(
const double &_roll,
const double &_pitch,
82 public:
void Invert();
89 Quaternion q(this->w, this->x, this->y, this->z);
92 s = q.
w * q.
w + q.
x * q.
x + q.
y * q.
y + q.
z * q.
z;
114 public:
void SetToIdentity();
125 public:
void Normalize();
132 public:
void SetFromAxis(
double _x,
double _y,
double _z,
double _a);
137 public:
void SetFromAxis(
const Vector3 &_axis,
double _a);
144 public:
void Set(
double _u,
double _x,
double _y,
double _z);
149 public:
void SetFromEuler(
const Vector3 &_vec);
155 public:
void SetFromEuler(
double _roll,
double _pitch,
double _yaw);
159 public:
Vector3 GetAsEuler()
const;
169 public:
static Quaternion EulerToQuaternion(
double _x,
175 public:
double GetRoll();
179 public:
double GetPitch();
183 public:
double GetYaw();
188 public:
void GetAsAxis(
Vector3 &_axis,
double &_angle)
const;
192 public:
void Scale(
double _scale);
220 this->w*_q.
w - this->x*_q.
x - this->y*_q.
y - this->z*_q.
z,
221 this->w*_q.
x + this->x*_q.
w + this->y*_q.
z - this->z*_q.
y,
222 this->w*_q.
y - this->x*_q.
z + this->y*_q.
w + this->z*_q.
x,
223 this->w*_q.
z + this->x*_q.
y - this->y*_q.
x + this->z*_q.
w);
229 public:
Quaternion operator*(
const double &_f)
const;
243 public:
bool operator ==(
const Quaternion &_qt)
const;
248 public:
bool operator!=(
const Quaternion &_qt)
const;
260 tmp = (*this) * (tmp * this->GetInverse());
271 public:
bool IsFinite()
const;
276 if (!std::isfinite(this->x))
278 if (!std::isfinite(this->y))
280 if (!std::isfinite(this->z))
282 if (!std::isfinite(this->w))
295 public:
Matrix3 GetAsMatrix3()
const;
299 public:
Matrix4 GetAsMatrix4()
const;
303 public:
Vector3 GetXAxis()
const;
307 public:
Vector3 GetYAxis()
const;
311 public:
Vector3 GetZAxis()
const;
315 public:
void Round(
int _precision);
320 public:
double Dot(
const Quaternion &_q)
const;
333 const Quaternion &_rkQ,
bool _shortestPath =
false);
343 const Quaternion &_rkQ,
bool _shortestPath =
false);
352 const double _deltaT)
const;
386 Angle roll, pitch, yaw;
389 _in.setf(std::ios_base::skipws);
390 _in >> roll >> pitch >> yaw;
double z
Attributes of the quaternion.
Definition: Quaternion.hh:364
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
A 3x3 matrix class.
Definition: Matrix4.hh:39
double x
X location.
Definition: Vector3.hh:302
Vector3 RotateVector(const Vector3 &_vec) const
Rotate a vector using the quaternion.
Definition: Quaternion.hh:257
void SetFromEuler(const Vector3 &_vec)
Set the quaternion from Euler angles.
double z
Z location.
Definition: Vector3.hh:308
Quaternion operator*(const Quaternion &_q) const
Multiplication operator.
Definition: Quaternion.hh:217
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:168
A 3x3 matrix class.
Definition: Matrix3.hh:34
void Correct()
Correct any nan.
Definition: Quaternion.hh:274
double w
Attributes of the quaternion.
Definition: Quaternion.hh:355
A quaternion class.
Definition: Quaternion.hh:41
friend std::istream & operator>>(std::istream &_in, gazebo::math::Quaternion &_q)
Stream extraction operator.
Definition: Quaternion.hh:383
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
double y
Attributes of the quaternion.
Definition: Quaternion.hh:361
Quaternion GetInverse() const
Get the inverse of this quaternion.
Definition: Quaternion.hh:86
double x
Attributes of the quaternion.
Definition: Quaternion.hh:358
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:179
An angle and related functions.
Definition: Angle.hh:52
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
double y
Y location.
Definition: Vector3.hh:305
friend std::ostream & operator<<(std::ostream &_out, const gazebo::math::Quaternion &_q)
Stream insertion operator.
Definition: Quaternion.hh:370
Vector3 GetAsEuler() const
Return the rotation in Euler angles.