| tf2
    master
    tf2 maintains the relationship between coordinate frames in a tree structure buffered in time, and lets the user transform points, vectors, etc between any two coordinate frames at any desired point in time. | 
 
 
 
Go to the documentation of this file.
   17 #ifndef TF2_QUATERNION_H_ 
   18 #define TF2_QUATERNION_H_ 
   40         : QuadWord(x, y, z, w) 
 
   59         setValue(axis.x() * s, axis.y() * s, axis.z() * s, 
 
   78         setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
 
   79             cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
 
   80             sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,
 
   81             cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw);
 
   99         setValue(sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, 
 
  100                          cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, 
 
  101                          cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, 
 
  102                          cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw); 
 
  108         m_floats[0] += q.x(); m_floats[1] += q.y(); m_floats[2] += q.z(); m_floats[3] += q.m_floats[3];
 
  117         m_floats[0] -= q.x(); m_floats[1] -= q.y(); m_floats[2] -= q.z(); m_floats[3] -= q.m_floats[3];
 
  126         m_floats[0] *= s; m_floats[1] *= s; m_floats[2] *= s; m_floats[3] *= s;
 
  136         setValue(m_floats[3] * q.x() + m_floats[0] * q.m_floats[3] + m_floats[1] * q.z() - m_floats[2] * q.y(),
 
  137             m_floats[3] * q.y() + m_floats[1] * q.m_floats[3] + m_floats[2] * q.x() - m_floats[0] * q.z(),
 
  138             m_floats[3] * q.z() + m_floats[2] * q.m_floats[3] + m_floats[0] * q.y() - m_floats[1] * q.x(),
 
  139             m_floats[3] * q.m_floats[3] - m_floats[0] * q.x() - m_floats[1] * q.y() - m_floats[2] * q.z());
 
  147         return m_floats[0] * q.x() + m_floats[1] * q.y() + m_floats[2] * q.z() + m_floats[3] * q.m_floats[3];
 
  177         return Quaternion(x() * s, y() * s, z() * s, m_floats[3] * s);
 
  239         if (m_floats[3] >= 0)
 
  253             return Vector3(1.0, 0.0, 0.0);  
 
  255         return Vector3(m_floats[0] / s, m_floats[1] / s, m_floats[2] / s);
 
  262         return Quaternion(-m_floats[0], -m_floats[1], -m_floats[2], m_floats[3]);
 
  271         return Quaternion(q1.x() + q2.x(), q1.y() + q2.y(), q1.z() + q2.z(), q1.m_floats[3] + q2.m_floats[3]);
 
  280         return Quaternion(q1.x() - q2.x(), q1.y() - q2.y(), q1.z() - q2.z(), q1.m_floats[3] - q2.m_floats[3]);
 
  288         return Quaternion( - q2.x(), - q2.y(),  - q2.z(),  - q2.m_floats[3]);
 
  296         if( diff.
dot(diff) > sum.
dot(sum) )
 
  307         if( diff.
dot(diff) < sum.
dot(sum) )
 
  327                           return Quaternion((m_floats[0] * s0 + -q.x() * s1) * d,
 
  328                                               (m_floats[1] * s0 + -q.y() * s1) * d,
 
  329                                               (m_floats[2] * s0 + -q.z() * s1) * d,
 
  330                                               (m_floats[3] * s0 + -q.m_floats[3] * s1) * d);
 
  332                           return Quaternion((m_floats[0] * s0 + q.x() * s1) * d,
 
  333                                               (m_floats[1] * s0 + q.y() * s1) * d,
 
  334                                               (m_floats[2] * s0 + q.z() * s1) * d,
 
  335                                               (m_floats[3] * s0 + q.m_floats[3] * s1) * d);
 
  361     return Quaternion(-q.x(), -q.y(), -q.z(), -q.w());
 
  369     return Quaternion(q1.w() * q2.x() + q1.x() * q2.w() + q1.y() * q2.z() - q1.z() * q2.y(),
 
  370         q1.w() * q2.y() + q1.y() * q2.w() + q1.z() * q2.x() - q1.x() * q2.z(),
 
  371         q1.w() * q2.z() + q1.z() * q2.w() + q1.x() * q2.y() - q1.y() * q2.x(),
 
  372         q1.w() * q2.w() - q1.x() * q2.x() - q1.y() * q2.y() - q1.z() * q2.z()); 
 
  378     return Quaternion( q.w() * w.x() + q.y() * w.z() - q.z() * w.y(),
 
  379         q.w() * w.y() + q.z() * w.x() - q.x() * w.z(),
 
  380         q.w() * w.z() + q.x() * w.y() - q.y() * w.x(),
 
  381         -q.x() * w.x() - q.y() * w.y() - q.z() * w.z()); 
 
  387     return Quaternion( w.x() * q.w() + w.y() * q.z() - w.z() * q.y(),
 
  388         w.y() * q.w() + w.z() * q.x() - w.x() * q.z(),
 
  389         w.z() * q.w() + w.x() * q.y() - w.y() * q.x(),
 
  390         -w.x() * q.x() - w.y() * q.y() - w.z() * q.z()); 
 
  437     return q1.
slerp(q2, t);
 
  445     return Vector3(q.getX(),q.getY(),q.getZ());
 
  451     Vector3 c = v0.cross(v1);
 
  464     return Quaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f);
 
  
TF2SIMD_FORCE_INLINE Quaternion operator+(const Quaternion &q2) const
Return the sum of this quaternion and the other.
Definition: Quaternion.h:268
TF2SIMD_FORCE_INLINE tf2Scalar dot(const Quaternion &q1, const Quaternion &q2)
Calculate the dot product between two quaternions.
Definition: Quaternion.h:395
Quaternion & operator/=(const tf2Scalar &s)
Inversely scale this quaternion.
Definition: Quaternion.h:193
static const Quaternion & getIdentity()
Definition: Quaternion.h:345
TF2SIMD_FORCE_INLINE Quaternion shortestArcQuatNormalize2(Vector3 &v0, Vector3 &v1)
Definition: Quaternion.h:468
const TF2SIMD_FORCE_INLINE tf2Scalar & getW() const
Definition: Quaternion.h:351
tf2Scalar getAngleShortestPath() const
Return the angle [0, Pi] of rotation represented by this quaternion along the shortest path.
Definition: Quaternion.h:236
#define TF2SIMD_EPSILON
Definition: Scalar.h:202
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
Set the quaternion using fixed axis RPY.
Definition: Quaternion.h:88
TF2SIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
Return the inverse of a quaternion.
Definition: Quaternion.h:424
TF2SIMD_FORCE_INLINE tf2Scalar angleShortestPath(const Quaternion &q1, const Quaternion &q2)
Return the shortest angle between two quaternions.
Definition: Quaternion.h:417
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sin(tf2Scalar x)
Definition: Scalar.h:180
TF2SIMD_FORCE_INLINE Quaternion operator-() const
Return the negative of this quaternion This simply negates each element.
Definition: Quaternion.h:285
Quaternion & normalize()
Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
Definition: Quaternion.h:167
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sqrt(tf2Scalar x)
Definition: Scalar.h:177
tf2Scalar angle(const Quaternion &q) const
Return the half angle between this quaternion and the other.
Definition: Quaternion.h:208
Quaternion operator/(const tf2Scalar &s) const
Return an inversely scaled versionof this quaternion.
Definition: Quaternion.h:184
TF2SIMD_FORCE_INLINE Quaternion operator-(const Quaternion &q2) const
Return the difference between this quaternion and the other.
Definition: Quaternion.h:277
Quaternion()
No initialization constructor.
Definition: Quaternion.h:33
Quaternion slerp(const Quaternion &q, const tf2Scalar &t) const
Return the quaternion which is the result of Spherical Linear Interpolation between this and the othe...
Definition: Quaternion.h:318
Quaternion(const tf2Scalar &x, const tf2Scalar &y, const tf2Scalar &z, const tf2Scalar &w)
Constructor from scalars.
Definition: Quaternion.h:39
Vector3 getAxis() const
Return the axis of the rotation represented by this quaternion.
Definition: Quaternion.h:249
TF2SIMD_FORCE_INLINE tf2Scalar tf2Acos(tf2Scalar x)
Definition: Scalar.h:182
TF2SIMD_FORCE_INLINE Quaternion & operator+=(const Quaternion &q)
Add two quaternions.
Definition: Quaternion.h:106
TF2SIMD_FORCE_INLINE Vector3 operator*(const Matrix3x3 &m, const Vector3 &v)
Definition: Matrix3x3.h:611
tf2Scalar getAngle() const
Return the angle [0, 2Pi] of rotation represented by this quaternion.
Definition: Quaternion.h:228
#define tf2Assert(x)
Definition: Scalar.h:144
tf2Scalar length() const
Return the length of the quaternion.
Definition: Quaternion.h:159
#define TF2SIMD_FORCE_INLINE
Definition: Scalar.h:129
TF2SIMD_FORCE_INLINE void tf2PlaneSpace1(const Vector3 &n, Vector3 &p, Vector3 &q)
Definition: Vector3.h:660
TF2SIMD_FORCE_INLINE Quaternion farthest(const Quaternion &qd) const
Definition: Quaternion.h:291
void setRotation(const Vector3 &axis, const tf2Scalar &angle)
Set the rotation using axis angle notation.
Definition: Quaternion.h:54
Quaternion & operator*=(const Quaternion &q)
Multiply this quaternion by q on the right.
Definition: Quaternion.h:134
TF2SIMD_FORCE_INLINE tf2Scalar tf2Cos(tf2Scalar x)
Definition: Scalar.h:179
Quaternion inverse() const
Return the inverse of this quaternion.
Definition: Quaternion.h:260
tf2Scalar dot(const Quaternion &q) const
Return the dot product between this quaternion and another.
Definition: Quaternion.h:145
TF2SIMD_FORCE_INLINE Vector3 quatRotate(const Quaternion &rotation, const Vector3 &v)
Definition: Quaternion.h:441
void setEuler(const tf2Scalar &yaw, const tf2Scalar &pitch, const tf2Scalar &roll)
Set the quaternion using Euler angles.
Definition: Quaternion.h:67
Definition: buffer_core.h:55
#define TF2_PUBLIC
Definition: visibility_control.h:58
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
Return the half angle between two quaternions.
Definition: Quaternion.h:410
The Quaternion implements quaternion to perform linear algebra rotations in combination with Matrix3x...
Definition: Quaternion.h:29
Quaternion normalized() const
Return a normalized version of this quaternion.
Definition: Quaternion.h:201
TF2SIMD_FORCE_INLINE Quaternion slerp(const Quaternion &q1, const Quaternion &q2, const tf2Scalar &t)
Return the result of spherical linear interpolation betwen two quaternions.
Definition: Quaternion.h:435
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
Return the length of a quaternion.
Definition: Quaternion.h:403
double tf2Scalar
The tf2Scalar type abstracts floating point numbers, to easily switch between double and single float...
Definition: Scalar.h:159
TF2SIMD_FORCE_INLINE Quaternion operator*(const tf2Scalar &s) const
Return a scaled version of this quaternion.
Definition: Quaternion.h:175
TF2SIMD_FORCE_INLINE Quaternion operator-(const Quaternion &q)
Return the negative of a quaternion.
Definition: Quaternion.h:359
TF2SIMD_FORCE_INLINE Quaternion nearest(const Quaternion &qd) const
Definition: Quaternion.h:302
Quaternion & operator*=(const tf2Scalar &s)
Scale this quaternion.
Definition: Quaternion.h:124
TF2SIMD_FORCE_INLINE tf2Scalar tf2Pow(tf2Scalar x, tf2Scalar y)
Definition: Scalar.h:188
Quaternion & operator-=(const Quaternion &q)
Sutf2ract out a quaternion.
Definition: Quaternion.h:115
tf2Scalar angleShortestPath(const Quaternion &q) const
Return the angle between this quaternion and the other along the shortest path.
Definition: Quaternion.h:217
TF2SIMD_FORCE_INLINE Quaternion shortestArcQuat(const Vector3 &v0, const Vector3 &v1)
Definition: Quaternion.h:449
tf2Scalar length2() const
Return the length squared of the quaternion.
Definition: Quaternion.h:152
Quaternion(const Vector3 &axis, const tf2Scalar &angle)
Axis angle Constructor.
Definition: Quaternion.h:46