wfmath
1.0.3
A math library for the Worldforge system.
|
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();}
200 #endif // WFMATH_QUATERNION_H
Quaternion & rotation(int axis, CoordType angle)
sets the Quaternion to a rotation by angle around axis
Quaternion & rotate(const RotMatrix< 3 > &)
Rotate quaternion using the matrix.
CoordType scalar() const
returns the scalar (w) part of the Quaternion
Quaternion()
Construct a Quaternion.
const Vector< 3 > & vector() const
returns the Vector (x, y, z) part of the quaternion
Quaternion inverse() const
returns the inverse of the Quaternion
AtlasOutType toAtlas() const
Create an Atlas object from the Quaternion.
Quaternion & identity()
Set the Quaternion to the identity rotation.
Quaternion(const Vector< 3 > &axis)
Construct a Quaternion giving a rotation around the Vector axis.
Quaternion & rotate(const Quaternion &q)
rotate the quaternion using another quaternion
bool fromRotMatrix(const RotMatrix< 3 > &m)
set a Quaternion's value from a RotMatrix
unsigned age() const
current round-off age
void fromAtlas(const AtlasInType &a)
Set the Quaternion's value to that given by an Atlas object.
Generic library namespace.
static const Quaternion & IDENTITY()
Vector & zero()
Zero the components of a vector.
A dim dimensional vector.
void normalize()
normalize to remove accumulated round-off error
Quaternion(int axis, CoordType angle)
Construct a Quaternion giving a rotation around axis by angle.
double CoordType
Basic floating point type.
Quaternion(const Vector< 3 > &axis, CoordType angle)
Construct a Quaternion giving a rotation around the Vector axis by angle.
Quaternion(const Quaternion &p)=default
Construct a copy of a Quaternion.
Quaternion(const AtlasInType &a)
Construct a Quaternion from an Atlas::Message::Object.