26 #ifndef WFMATH_QUATERNION_H
27 #define WFMATH_QUATERNION_H
29 #include <wfmath/vector.h>
30 #include <wfmath/rotmatrix.h>
51 Quaternion() : m_w(0), m_vec{}, m_valid(false), m_age(0){}
71 m_valid(false), m_age(0)
77 m_valid(false), m_age(0)
82 friend std::ostream& operator<<(std::ostream& os,
const Quaternion& p);
83 friend std::istream& operator>>(std::istream& is,
Quaternion& p);
96 bool operator== (
const Quaternion& rhs)
const {
return isEqualTo(rhs);}
97 bool operator!= (
const Quaternion& rhs)
const {
return !isEqualTo(rhs);}
99 bool isValid()
const {
return m_valid;}
187 unsigned age()
const {
return m_age;}
190 Quaternion(
bool valid) : m_w(0), m_vec(), m_valid(valid), m_age(1) {}
191 void checkNormalization() {
if(m_age >= WFMATH_MAX_NORM_AGE && m_valid)
normalize();}
Quaternion(const AtlasInType &a)
Construct a Quaternion from an Atlas::Message::Object.
const Vector< 3 > & vector() const
returns the Vector (x, y, z) part of the quaternion
Quaternion inverse() const
returns the inverse of the Quaternion
Quaternion & identity()
Set the Quaternion to the identity rotation.
CoordType scalar() const
returns the scalar (w) part of the Quaternion
void normalize()
normalize to remove accumulated round-off error
bool fromRotMatrix(const RotMatrix< 3 > &m)
set a Quaternion's value from a RotMatrix
void fromAtlas(const AtlasInType &a)
Set the Quaternion's value to that given by an Atlas object.
Quaternion(const Quaternion &p)=default
Construct a copy of a Quaternion.
Quaternion & rotate(const RotMatrix< 3 > &)
Rotate quaternion using the matrix.
Quaternion(const Vector< 3 > &axis, CoordType angle)
Construct a Quaternion giving a rotation around the Vector axis by angle.
unsigned age() const
current round-off age
static const Quaternion & IDENTITY()
Quaternion & rotation(int axis, CoordType angle)
sets the Quaternion to a rotation by angle around axis
Quaternion & rotate(const Quaternion &q)
rotate the quaternion using another quaternion
Quaternion(int axis, CoordType angle)
Construct a Quaternion giving a rotation around axis by angle.
Quaternion()
Construct a Quaternion.
AtlasOutType toAtlas() const
Create an Atlas object from the Quaternion.
Quaternion(const Vector< 3 > &axis)
Construct a Quaternion giving a rotation around the Vector axis.
A dim dimensional vector.
Vector & zero()
Zero the components of a vector.
Generic library namespace.
double CoordType
Basic floating point type.