8 #error This class is not to be included by the user directly. Use Quatd.h or Quatf.h instead.
25 QUAT(REAL
x, REAL
y, REAL
z, REAL
w);
35 static QUAT identity() {
return QUAT((REAL) 0.0, (REAL) 0.0, (REAL) 0.0, (REAL) 1.0); }
36 void set_identity() { w = (REAL) 1.0; x = y = z = (REAL) 0.0; }
38 void lerp(
const QUAT& q, REAL alpha);
41 static QUAT rpy(REAL roll, REAL pitch, REAL yaw);
44 void to_rpy(REAL& roll, REAL& pitch, REAL& yaw)
const;
58 void calc_generalized_force(
const VECTOR3& t, REAL gt[4])
const;
59 unsigned size()
const {
return 4; }
99 static REAL sgn(REAL x) {
return (x >= (REAL) 0.0) ? (REAL) 1.0 : (REAL) -1.0; }
107 static REAL safe_sqrt(REAL x) {
return (x < (REAL) 0.0) ? (REAL) 0.0 : std::sqrt(x); }
110 QUAT operator*(REAL scalar,
const QUAT& q);
111 std::ostream& operator<<(std::ostream& out,
const QUAT& q);
VECTOR3 G_mult(REAL qx, REAL qy, REAL qz, REAL qw) const
Multiplies the matrix 'G' by a quaternion vector.
Definition: Quat.cpp:169
QUAT & operator*=(const QUAT &q)
Multiplies this by q and stores the result in this
Definition: Quat.cpp:580
QUAT & invert()
Computes the inverse orientation represented by this quaternion in place.
Definition: Quat.cpp:451
QUAT & operator-=(const QUAT &q)
Subtracts one quaternion from another.
Definition: Quat.cpp:504
QUAT()
Default constructor.
Definition: Quat.cpp:11
bool unit() const
Determines whether this is a unit quaternion.
Definition: Quat.cpp:491
Quaternion class used for orientation.
Definition: Quat.h:21
QUAT operator/(const QUAT &q) const
Multiplies inv(q) by this and returns the result.
Definition: Quat.cpp:524
QUAT & operator=(const VECTORN &v)
Sets the quaternion based on the given parameters.
Definition: Quat.cpp:646
REAL norm_sq() const
Calculates the squared magnitude of a quaternion.
Definition: Quat.cpp:594
static QUAT rpy(REAL roll, REAL pitch, REAL yaw)
Sets up the quaternion from roll-pitch-yaw.
Definition: Quat.cpp:369
static QUAT deriv(const QUAT &q, const VECTOR3 &w)
Computes the derivative of a quaternion given current orientation and angular velocity.
Definition: Quat.cpp:242
Class for representation of orientation by an angle around an axis.
Definition: AAngle.h:15
REAL norm_inf() const
Returns the l-infinity norm of the quaternion components.
Definition: Quat.cpp:587
REAL w
Fourth quaternion component.
Definition: Quat.h:96
REAL x
First quaternion component.
Definition: Quat.h:87
static QUAT dderiv(const QUAT &q, const VECTOR3 &omega, const VECTOR3 &alpha)
Calculates the second derivative of a quaternion.
Definition: Quat.cpp:269
REAL y
Second quaternion component.
Definition: Quat.h:90
void to_rpy(REAL &roll, REAL &pitch, REAL &yaw) const
Converts quaternion to roll/pitch/yaw.
Definition: Quat.cpp:393
QUAT operator-(const QUAT &q) const
Subtracts a quaternion from this
Definition: Quat.cpp:498
static QUAT zero()
Constructs a zero quaternion.
Definition: Quat.cpp:33
VECTOR3 L_mult(REAL qx, REAL qy, REAL qz, REAL qw) const
Multiplies the 3x4 matrix 'L' times a four dimensional array.
Definition: Quat.cpp:123
void conjugate()
Negates the value of each of the x, y, and z coordinates in place.
Definition: Quat.cpp:97
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
static bool rel_equal(const QUAT &q1, const QUAT &q2, REAL tol=-1.0)
Determines whether two poses in 3D are relatively equivalent.
Definition: Quat.cpp:336
REAL magnitude() const
Calculates the magnitude of a quaternion.
Definition: Quat.cpp:600
QUAT L_transpose_mult(const VECTOR3 &v) const
Multiplies the transpose of the matrix 'L' by a vector.
Definition: Quat.cpp:217
QUAT & operator+=(const QUAT &q)
Adds this quaon to another and stores the result in this
Definition: Quat.cpp:517
A three-dimensional floating point vector used for representing points and vectors in 3D with associa...
Definition: Vector3.h:15
A three-dimensional floating point vector used for representing points and vectors in 3D and without ...
Definition: Origin3.h:16
static REAL calc_angle(const QUAT &q1, const QUAT &q2)
Calculates the angle between two orientations.
Definition: Quat.cpp:348
static VECTOR3 to_omega(const QUAT &q, const QUAT &qd)
Computes the angular velocity of a body given the current quaternion orientation and the quaternion v...
Definition: Quat.cpp:255
void lerp(const QUAT &q, REAL alpha)
Performs linear interpolation between this and q.
Definition: Quat.cpp:297
REAL z
Third quaterion component.
Definition: Quat.h:93
REAL & operator[](unsigned i)
Gets the i'th component of the quaternion.
Definition: Quat.cpp:47
A 3x3 matrix that may be used for orientation, inertia tensors, etc.
Definition: Matrix3.h:20
QUAT G_transpose_mult(const VECTOR3 &v) const
Multiplies the transpose of the matrix 'G' by a vector.
Definition: Quat.cpp:190
QUAT operator*(const QUAT &q) const
Multiplies this by q and returns the result.
Definition: Quat.cpp:530
void normalize()
Normalizes this quaternion in place.
Definition: Quat.cpp:464
QUAT operator+(const QUAT &q) const
Adds this quaternion to another and returns the result in a new quaternion.
Definition: Quat.cpp:511
void slerp(const QUAT &q, REAL alpha)
Performs spherical linear interpolation between this and q.
Definition: Quat.cpp:284