osg::Quat Class Reference

`#include <Quat>`

## Public Types

enum | { num_components = 4 }
typedef double | value_type

## Public Member Functions

| Quat ()
| Quat (value_type x, value_type y, value_type z, value_type w)
| Quat (const Vec4f &v)
| Quat (const Vec4d &v)
| Quat (value_type angle, const Vec3f &axis)
| Quat (value_type angle, const Vec3d &axis)
| Quat (value_type angle1, const Vec3f &axis1, value_type angle2, const Vec3f &axis2, value_type angle3, const Vec3f &axis3)
| Quat (value_type angle1, const Vec3d &axis1, value_type angle2, const Vec3d &axis2, value_type angle3, const Vec3d &axis3)
| Quat (const Quat &q)
Quat & | operator= (const Quat &v)
bool | operator== (const Quat &v) const
bool | operator!= (const Quat &v) const
bool | operator< (const Quat &v) const
Vec4d | asVec4 () const
Vec3d | asVec3 () const
void | set (value_type x, value_type y, value_type z, value_type w)
void | set (const osg::Vec4f &v)
void | set (const osg::Vec4d &v)
void | set (const Matrixf &matrix)
void | set (const Matrixd &matrix)
void | get (Matrixf &matrix) const
void | get (Matrixd &matrix) const
value_type & | operator[] (int i)
value_type | operator[] (int i) const
value_type & | x ()
value_type & | y ()
value_type & | z ()
value_type & | w ()
value_type | x () const
value_type | y () const
value_type | z () const
value_type | w () const
bool | zeroRotation () const
const Quat | operator* (value_type rhs) const
| Multiply by scalar.
Quat & | operator*= (value_type rhs)
| Unary multiply by scalar.
const Quat | operator* (const Quat &rhs) const
| Binary multiply.
Quat & | operator*= (const Quat &rhs)
| Unary multiply.
Quat | operator/ (value_type rhs) const
| Divide by scalar.
Quat & | operator/= (value_type rhs)
| Unary divide by scalar.
const Quat | operator/ (const Quat &denom) const
| Binary divide.
Quat & | operator/= (const Quat &denom)
| Unary divide.
const Quat | operator+ (const Quat &rhs) const
| Binary addition.
Quat & | operator+= (const Quat &rhs)
| Unary addition.
const Quat | operator- (const Quat &rhs) const
| Binary subtraction.
Quat & | operator-= (const Quat &rhs)
| Unary subtraction.
const Quat | operator- () const
value_type | length () const
| Length of the quaternion = sqrt( vec . vec ).
value_type | length2 () const
| Length of the quaternion = vec . vec.
Quat | conj () const
| Conjugate.
const Quat | inverse () const
| Multiplicative inverse method: q^(-1) = q^*‍/(q.q^*).
void | makeRotate (value_type angle, value_type x, value_type y, value_type z)
void | makeRotate (value_type angle, const Vec3f &vec)
void | makeRotate (value_type angle, const Vec3d &vec)
void | makeRotate (value_type angle1, const Vec3f &axis1, value_type angle2, const Vec3f &axis2, value_type angle3, const Vec3f &axis3)
void | makeRotate (value_type angle1, const Vec3d &axis1, value_type angle2, const Vec3d &axis2, value_type angle3, const Vec3d &axis3)
void | makeRotate (const Vec3f &vec1, const Vec3f &vec2)
void | makeRotate (const Vec3d &vec1, const Vec3d &vec2)
void | makeRotate_original (const Vec3d &vec1, const Vec3d &vec2)
void | getRotate (value_type &angle, value_type &x, value_type &y, value_type &z) const
void | getRotate (value_type &angle, Vec3f &vec) const
void | getRotate (value_type &angle, Vec3d &vec) const
void | slerp (value_type t, const Quat &from, const Quat &to)
Vec3f | operator* (const Vec3f &v) const
Vec3d | operator* (const Vec3d &v) const

## Public Attributes

value_type | _v [4]

## Detailed Description

A quaternion class. It can be used to represent an orientation in 3D space.

## Member Typedef Documentation

## value_type

typedef double osg::Quat::value_type

Data type of vector components.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

Number of vector components.

Enumerator
num_components |

## Constructor & Destructor Documentation

## Quat() [1/9]

osg::Quat::Quat | ( |  | ) |

inline

References _v.

Referenced by conj(), inverse(), operator!=(), operator*(), operator*(), operator*=(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/(), operator/=(), operator/=(), operator<(), operator=(), operator==(), Quat(), and slerp().

## Quat() [2/9]

osg::Quat::Quat | ( | value_type | x,
|  | value_type | y,
|  | value_type | z,
|  | value_type | w )

inline

References _v, w(), x(), y(), and z().

## Quat() [3/9]

osg::Quat::Quat | ( | const Vec4f & | v | ) |

inline

References _v, osg::Vec4f::w(), osg::Vec4f::x(), osg::Vec4f::y(), and osg::Vec4f::z().

## Quat() [4/9]

osg::Quat::Quat | ( | const Vec4d & | v | ) |

inline

References _v, osg::Vec4d::w(), osg::Vec4d::x(), osg::Vec4d::y(), and osg::Vec4d::z().

## Quat() [5/9]

osg::Quat::Quat | ( | value_type | angle,
|  | const Vec3f & | axis )

inline

References makeRotate().

## Quat() [6/9]

osg::Quat::Quat | ( | value_type | angle,
|  | const Vec3d & | axis )

inline

References makeRotate().

## Quat() [7/9]

osg::Quat::Quat | ( | value_type | angle1,
|  | const Vec3f & | axis1,
|  | value_type | angle2,
|  | const Vec3f & | axis2,
|  | value_type | angle3,
|  | const Vec3f & | axis3 )

inline

References makeRotate().

## Quat() [8/9]

osg::Quat::Quat | ( | value_type | angle1,
|  | const Vec3d & | axis1,
|  | value_type | angle2,
|  | const Vec3d & | axis2,
|  | value_type | angle3,
|  | const Vec3d & | axis3 )

inline

References makeRotate().

## Quat() [9/9]

osg::Quat::Quat | ( | const Quat & | q | ) |

inline

References _v, and Quat().

## Member Function Documentation

## asVec3()

Vec3d osg::Quat::asVec3 | ( |  | ) | const

inline

References _v.

## asVec4()

Vec4d osg::Quat::asVec4 | ( |  | ) | const

inline

References _v.

Referenced by osgAnimation::TemplateTarget< UsingType >::lerp().

## conj()

Quat osg::Quat::conj | ( |  | ) | const

inline

Conjugate.

References _v, and Quat().

Referenced by inverse().

## get() [1/2]

void osg::Quat::get | ( | Matrixd & | matrix | ) | const

## get() [2/2]

void osg::Quat::get | ( | Matrixf & | matrix | ) | const

## getRotate() [1/3]

void osg::Quat::getRotate | ( | value_type & | angle,
|  | value_type & | x,
|  | value_type & | y,
|  | value_type & | z ) const

Return the angle and vector components represented by the quaternion.

References x(), y(), and z().

## getRotate() [2/3]

void osg::Quat::getRotate | ( | value_type & | angle,
|  | Vec3d & | vec ) const

Return the angle and vector represented by the quaternion.

## getRotate() [3/3]

void osg::Quat::getRotate | ( | value_type & | angle,
|  | Vec3f & | vec ) const

Return the angle and vector represented by the quaternion.

## inverse()

const Quat osg::Quat::inverse | ( |  | ) | const

inline

Multiplicative inverse method: q^(-1) = q^*‍/(q.q^*).

References conj(), length2(), and Quat().

Referenced by operator/(), and operator/=().

## length()

value_type osg::Quat::length | ( |  | ) | const

inline

Length of the quaternion = sqrt( vec . vec ).

References _v.

## length2()

value_type osg::Quat::length2 | ( |  | ) | const

inline

Length of the quaternion = vec . vec.

References _v.

Referenced by inverse().

## makeRotate() [1/7]

void osg::Quat::makeRotate | ( | const Vec3d & | vec1,
|  | const Vec3d & | vec2 )

Make a rotation Quat which will rotate vec1 to vec2. Generally take a dot product to get the angle between these and then use a cross product to get the rotation axis Watch out for the two special cases of when the vectors are co-incident or opposite in direction.

## makeRotate() [2/7]

void osg::Quat::makeRotate | ( | const Vec3f & | vec1,
|  | const Vec3f & | vec2 )

Make a rotation Quat which will rotate vec1 to vec2. Generally take a dot product to get the angle between these and then use a cross product to get the rotation axis Watch out for the two special cases when the vectors are co-incident or opposite in direction.

## makeRotate() [3/7]

void osg::Quat::makeRotate | ( | value_type | angle,
|  | const Vec3d & | vec )

## makeRotate() [4/7]

void osg::Quat::makeRotate | ( | value_type | angle,
|  | const Vec3f & | vec )

## makeRotate() [5/7]

void osg::Quat::makeRotate | ( | value_type | angle,
|  | value_type | x,
|  | value_type | y,
|  | value_type | z )

References x(), y(), and z().

Referenced by Quat(), Quat(), Quat(), and Quat().

## makeRotate() [6/7]

void osg::Quat::makeRotate | ( | value_type | angle1,
|  | const Vec3d & | axis1,
|  | value_type | angle2,
|  | const Vec3d & | axis2,
|  | value_type | angle3,
|  | const Vec3d & | axis3 )

## makeRotate() [7/7]

void osg::Quat::makeRotate | ( | value_type | angle1,
|  | const Vec3f & | axis1,
|  | value_type | angle2,
|  | const Vec3f & | axis2,
|  | value_type | angle3,
|  | const Vec3f & | axis3 )

## makeRotate_original()

void osg::Quat::makeRotate_original | ( | const Vec3d & | vec1,
|  | const Vec3d & | vec2 )

## operator!=()

bool osg::Quat::operator!= | ( | const Quat & | v | ) | const

inline

References _v, and Quat().

## operator*() [1/4]

const Quat osg::Quat::operator* | ( | const Quat & | rhs | ) | const

inline

Binary multiply.

References _v, and Quat().

## operator*() [2/4]

Vec3d osg::Quat::operator* | ( | const Vec3d & | v | ) | const

inline

Rotate a vector by this quaternion.

References _v.

## operator*() [3/4]

Vec3f osg::Quat::operator* | ( | const Vec3f & | v | ) | const

inline

Rotate a vector by this quaternion.

References _v.

## operator*() [4/4]

const Quat osg::Quat::operator* | ( | value_type | rhs | ) | const

inline

Multiply by scalar.

References _v, and Quat().

## operator*=() [1/2]

Quat & osg::Quat::operator*= | ( | const Quat & | rhs | ) |

inline

Unary multiply.

References _v, Quat(), x(), y(), and z().

## operator*=() [2/2]

Quat & osg::Quat::operator*= | ( | value_type | rhs | ) |

inline

Unary multiply by scalar.

References _v, and Quat().

## operator+()

const Quat osg::Quat::operator+ | ( | const Quat & | rhs | ) | const

inline

Binary addition.

References _v, and Quat().

## operator+=()

Quat & osg::Quat::operator+= | ( | const Quat & | rhs | ) |

inline

Unary addition.

References _v, and Quat().

## operator-() [1/2]

const Quat osg::Quat::operator- | ( |  | ) | const

inline

Negation operator - returns the negative of the quaternion. Basically just calls operator - () on the Vec4

References _v, and Quat().

## operator-() [2/2]

const Quat osg::Quat::operator- | ( | const Quat & | rhs | ) | const

inline

Binary subtraction.

References _v, and Quat().

## operator-=()

Quat & osg::Quat::operator-= | ( | const Quat & | rhs | ) |

inline

Unary subtraction.

References _v, and Quat().

## operator/() [1/2]

const Quat osg::Quat::operator/ | ( | const Quat & | denom | ) | const

inline

Binary divide.

References inverse(), and Quat().

## operator/() [2/2]

Quat osg::Quat::operator/ | ( | value_type | rhs | ) | const

inline

Divide by scalar.

References _v, and Quat().

## operator/=() [1/2]

Quat & osg::Quat::operator/= | ( | const Quat & | denom | ) |

inline

Unary divide.

References inverse(), and Quat().

## operator/=() [2/2]

Quat & osg::Quat::operator/= | ( | value_type | rhs | ) |

inline

Unary divide by scalar.

References _v, and Quat().

## operator<()

bool osg::Quat::operator< | ( | const Quat & | v | ) | const

inline

References _v, and Quat().

## operator=()

Quat & osg::Quat::operator= | ( | const Quat & | v | ) |

inline

References _v, and Quat().

## operator==()

bool osg::Quat::operator== | ( | const Quat & | v | ) | const

inline

References _v, and Quat().

## operator[]() [1/2]

value_type & osg::Quat::operator[] | ( | int | i | ) |

inline

References _v.

## operator[]() [2/2]

value_type osg::Quat::operator[] | ( | int | i | ) | const

inline

References _v.

## set() [1/5]

void osg::Quat::set | ( | const Matrixd & | matrix | ) |

## set() [2/5]

void osg::Quat::set | ( | const Matrixf & | matrix | ) |

## set() [3/5]

void osg::Quat::set | ( | const osg::Vec4d & | v | ) |

inline

References _v, osg::Vec4d::w(), osg::Vec4d::x(), osg::Vec4d::y(), and osg::Vec4d::z().

## set() [4/5]

void osg::Quat::set | ( | const osg::Vec4f & | v | ) |

inline

References _v, osg::Vec4f::w(), osg::Vec4f::x(), osg::Vec4f::y(), and osg::Vec4f::z().

## set() [5/5]

void osg::Quat::set | ( | value_type | x,
|  | value_type | y,
|  | value_type | z,
|  | value_type | w )

inline

References _v, w(), x(), y(), and z().

## slerp()

void osg::Quat::slerp | ( | value_type | t,
|  | const Quat & | from,
|  | const Quat & | to )

Spherical Linear Interpolation. As t goes from 0 to 1, the Quat object goes from "from" to "to".

References Quat().

## w() [1/2]

value_type & osg::Quat::w | ( |  | ) |

inline

References _v.

Referenced by Quat(), and set().

## w() [2/2]

value_type osg::Quat::w | ( |  | ) | const

inline

References _v.

## x() [1/2]

value_type & osg::Quat::x | ( |  | ) |

inline

References _v.

Referenced by getRotate(), makeRotate(), operator*=(), Quat(), and set().

## x() [2/2]

value_type osg::Quat::x | ( |  | ) | const

inline

References _v.

## y() [1/2]

value_type & osg::Quat::y | ( |  | ) |

inline

References _v.

Referenced by getRotate(), makeRotate(), operator*=(), Quat(), and set().

## y() [2/2]

value_type osg::Quat::y | ( |  | ) | const

inline

References _v.

## z() [1/2]

value_type & osg::Quat::z | ( |  | ) |

inline

References _v.

Referenced by getRotate(), makeRotate(), operator*=(), Quat(), and set().

## z() [2/2]

value_type osg::Quat::z | ( |  | ) | const

inline

References _v.

## zeroRotation()

bool osg::Quat::zeroRotation | ( |  | ) | const

inline

return true if the Quat represents a zero rotation, and therefore can be ignored in computations.

References _v.

Referenced by osg::Matrixd::postMultRotate(), osg::Matrixf::postMultRotate(), osg::Matrixd::preMultRotate(), and osg::Matrixf::preMultRotate().

## Member Data Documentation

## _v

value_type osg::Quat::_v[4]

Referenced by asVec3(), asVec4(), conj(), length(), length2(), operator!=(), operator*(), operator*(), operator*(), operator*(), operator*=(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<(), osg::operator<<(), operator=(), operator==(), osg::operator>>(), operator[](), operator[](), Quat(), Quat(), Quat(), Quat(), Quat(), set(), set(), set(), w(), w(), x(), x(), y(), y(), z(), z(), and zeroRotation().

The documentation for this class was generated from the following file:

- Quat