OpenVDB 11.0.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
Quat< T > Class Template Reference

`#include <openvdb/math/Quat.h>`

## Public Types
using | value_type = T
using | ValueType = T

## Public Member Functions
| Quat ()=default
| Quat (T x, T y, T z, T w)
| Constructor with four arguments, e.g. Quatf q(1,2,3,4);.
| Quat (T *a)
| Constructor with array argument, e.g. float a[4]; Quatf q(a);.
| Quat (const Vec3< T > &axis, T angle)
| Quat (math::Axis axis, T angle)
| Constructor given rotation as axis and angle.
template<typename T1 >
| Quat (const Mat3< T1 > &rot)
| Constructor given a rotation matrix.
T & | x ()
| Reference to the component, e.g. q.x() = 4.5f;.
T & | y ()
T & | z ()
T & | w ()
T | x () const
| Get the component, e.g. float f = q.w();.
T | y () const
T | z () const
T | w () const
T & | operator[] (int i)
| Array style reference to the components, e.g. q[3] = 1.34f;.
T | operator[] (int i) const
| Array style constant reference to the components, e.g. float f = q[1];.
| operator T* ()
| Cast to T*.
| operator const T * () const
T & | operator() (int i)
| Alternative indexed reference to the elements.
T | operator() (int i) const
| Alternative indexed constant reference to the elements,.
T | angle () const
| Return angle of rotation.
Vec3< T > | axis () const
| Return axis of rotation.
Quat & | init (T x, T y, T z, T w)
| "this" quaternion gets initialized to [x, y, z, w]
Quat & | init ()
| "this" quaternion gets initialized to identity, same as setIdentity()
Quat & | setAxisAngle (const Vec3< T > &axis, T angle)
Quat & | setZero ()
| Set "this" vector to zero.
Quat & | setIdentity ()
| Set "this" vector to identity.
Vec3< T > | eulerAngles (RotationOrder rotationOrder) const
| Returns vector of x,y,z rotational components.
bool | operator== (const Quat &q) const
| Equality operator, does exact floating point comparisons.
bool | eq (const Quat &q, T eps=1.0e-7) const
| Test if "this" is equivalent to q with tolerance of eps value.
Quat & | operator+= (const Quat &q)
| Add quaternion q to "this" quaternion, e.g. q += q1;.
Quat & | operator-= (const Quat &q)
| Subtract quaternion q from "this" quaternion, e.g. q -= q1;.
Quat & | operator*= (T scalar)
| Scale "this" quaternion by scalar, e.g. q *= scalar;.
Quat | operator+ (const Quat &q) const
| Return (this+q), e.g. q = q1 + q2;.
Quat | operator- (const Quat &q) const
| Return (this-q), e.g. q = q1 - q2;.
Quat | operator* (const Quat &q) const
| Return (this*q), e.g. q = q1 * q2;.
Quat | operator*= (const Quat &q)
| Assigns this to (this*q), e.g. q *= q1;.
Quat | operator* (T scalar) const
| Return (this*scalar), e.g. q = q1 * scalar;.
Quat | operator/ (T scalar) const
| Return (this/scalar), e.g. q = q1 / scalar;.
Quat | operator- () const
| Negation operator, e.g. q = -q;.
Quat & | add (const Quat &q1, const Quat &q2)
Quat & | sub (const Quat &q1, const Quat &q2)
Quat & | mult (const Quat &q1, const Quat &q2)
Quat & | scale (T scale, const Quat &q)
T | dot (const Quat &q) const
| Dot product.
Quat | derivative (const Vec3< T > &omega) const
bool | normalize (T eps=T(1.0e-8))
| this = normalized this
Quat | unit () const
| this = normalized this
Quat | inverse (T tolerance=T(0)) const
| returns inverse of this
Quat | conjugate () const
Vec3< T > | rotateVector (const Vec3< T > &v) const
| Return rotated vector by "this" quaternion.
std::string | str () const
void | write (std::ostream &os) const
void | read (std::istream &is)

## Static Public Member Functions
static unsigned | numElements ()
static Quat | zero ()
| Predefined constants, e.g. Quat q = Quat::identity();.
static Quat | identity ()

## Static Public Attributes
static const int | size = 4

## Protected Attributes
T | mm [4]

## Friends
std::ostream & | operator<< (std::ostream &stream, const Quat &q)
| Output to the stream, e.g. std::cout << q << std::endl;.
Quat | slerp (const Quat &q1, const Quat &q2, T t, T tolerance)

## Member Typedef Documentation

## ◆ value_type

template<typename T >

using value_type = T

## ◆ ValueType

template<typename T >

using ValueType = T

## Constructor & Destructor Documentation

## ◆ Quat() [1/6]

template<typename T >

Quat | ( |  | ) |
| default

Trivial constructor, the quaternion is NOT initialized

Note
  destructor, copy constructor, assignment operator and move constructor are left to be defined by the compiler (default)

## ◆ Quat() [2/6]

template<typename T >

Quat | ( | T | x,
|  | T | y,
|  | T | z,
|  | T | w
| ) |  |
| inline

Constructor with four arguments, e.g. Quatf q(1,2,3,4);.

## ◆ Quat() [3/6]

template<typename T >

Quat | ( | T * | a | ) |
| inline

Constructor with array argument, e.g. float a[4]; Quatf q(a);.

## ◆ Quat() [4/6]

template<typename T >

Quat | ( | const Vec3< T > & | axis,
|  | T | angle
| ) |  |
| inline

Constructor given rotation as axis and angle, the axis must be unit vector

## ◆ Quat() [5/6]

template<typename T >

Quat | ( | math::Axis | axis,
|  | T | angle
| ) |  |
| inline

Constructor given rotation as axis and angle.

## ◆ Quat() [6/6]

template<typename T >
template<typename T1 >

Quat | ( | const Mat3< T1 > & | rot | ) |
| inline

Constructor given a rotation matrix.

## Member Function Documentation

## ◆ add()

template<typename T >

Quat & add | ( | const Quat< T > & | q1,
|  | const Quat< T > & | q2
| ) |  |
| inline

this = q1 + q2 "this", q1 and q2 need not be distinct objects, e.g. q.add(q1,q);

## ◆ angle()

template<typename T >

T angle | ( |  | ) | const
| inline

Return angle of rotation.

## ◆ axis()

template<typename T >

Vec3< T > axis | ( |  | ) | const
| inline

Return axis of rotation.

## ◆ conjugate()

template<typename T >

Quat conjugate | ( |  | ) | const
| inline

Return the conjugate of "this", same as invert without unit quaternion test

## ◆ derivative()

template<typename T >

Quat derivative | ( | const Vec3< T > & | omega | ) | const
| inline

Return the quaternion rate corrsponding to the angular velocity omega and "this" current rotation

## ◆ dot()

template<typename T >

T dot | ( | const Quat< T > & | q | ) | const
| inline

Dot product.

## ◆ eq()

template<typename T >

bool eq | ( | const Quat< T > & | q,
|  | T | eps = `1.0e-7`
| ) |  | const
| inline

Test if "this" is equivalent to q with tolerance of eps value.

## ◆ eulerAngles()

template<typename T >

Vec3< T > eulerAngles | ( | RotationOrder | rotationOrder | ) | const
| inline

Returns vector of x,y,z rotational components.

## ◆ identity()

template<typename T >

static Quat identity | ( |  | ) |
| inline static

## ◆ init() [1/2]

template<typename T >

Quat & init | ( |  | ) |
| inline

"this" quaternion gets initialized to identity, same as setIdentity()

## ◆ init() [2/2]

template<typename T >

Quat & init | ( | T | x,
|  | T | y,
|  | T | z,
|  | T | w
| ) |  |
| inline

"this" quaternion gets initialized to [x, y, z, w]

## ◆ inverse()

template<typename T >

Quat inverse | ( | T | tolerance = `T(0)` | ) | const
| inline

returns inverse of this

## ◆ mult()

template<typename T >

Quat & mult | ( | const Quat< T > & | q1,
|  | const Quat< T > & | q2
| ) |  |
| inline

this = q1 * q2 q1 and q2 must be distinct objects than "this", e.g. q.mult(q1,q2);

## ◆ normalize()

template<typename T >

bool normalize | ( | T | eps = `T(1.0e-8)` | ) |
| inline

this = normalized this

## ◆ numElements()

template<typename T >

static unsigned numElements | ( |  | ) |
| inline static

## ◆ operator const T *()

template<typename T >

operator const T * | ( |  | ) | const
| inline

## ◆ operator T*()

template<typename T >

operator T* | ( |  | ) |
| inline

Cast to T*.

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

template<typename T >

T & operator() | ( | int | i | ) |
| inline

Alternative indexed reference to the elements.

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

template<typename T >

T operator() | ( | int | i | ) | const
| inline

Alternative indexed constant reference to the elements,.

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

template<typename T >

Quat operator* | ( | const Quat< T > & | q | ) | const
| inline

Return (this*q), e.g. q = q1 * q2;.

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

template<typename T >

Quat operator* | ( | T | scalar | ) | const
| inline

Return (this*scalar), e.g. q = q1 * scalar;.

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

template<typename T >

Quat operator*= | ( | const Quat< T > & | q | ) |
| inline

Assigns this to (this*q), e.g. q *= q1;.

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

template<typename T >

Quat & operator*= | ( | T | scalar | ) |
| inline

Scale "this" quaternion by scalar, e.g. q *= scalar;.

## ◆ operator+()

template<typename T >

Quat operator+ | ( | const Quat< T > & | q | ) | const
| inline

Return (this+q), e.g. q = q1 + q2;.

## ◆ operator+=()

template<typename T >

Quat & operator+= | ( | const Quat< T > & | q | ) |
| inline

Add quaternion q to "this" quaternion, e.g. q += q1;.

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

template<typename T >

Quat operator- | ( |  | ) | const
| inline

Negation operator, e.g. q = -q;.

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

template<typename T >

Quat operator- | ( | const Quat< T > & | q | ) | const
| inline

Return (this-q), e.g. q = q1 - q2;.

## ◆ operator-=()

template<typename T >

Quat & operator-= | ( | const Quat< T > & | q | ) |
| inline

Subtract quaternion q from "this" quaternion, e.g. q -= q1;.

## ◆ operator/()

template<typename T >

Quat operator/ | ( | T | scalar | ) | const
| inline

Return (this/scalar), e.g. q = q1 / scalar;.

## ◆ operator==()

template<typename T >

bool operator== | ( | const Quat< T > & | q | ) | const
| inline

Equality operator, does exact floating point comparisons.

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

template<typename T >

T & operator[] | ( | int | i | ) |
| inline

Array style reference to the components, e.g. q[3] = 1.34f;.

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

template<typename T >

T operator[] | ( | int | i | ) | const
| inline

Array style constant reference to the components, e.g. float f = q[1];.

## ◆ read()

template<typename T >

void read | ( | std::istream & | is | ) |
| inline

## ◆ rotateVector()

template<typename T >

Vec3< T > rotateVector | ( | const Vec3< T > & | v | ) | const
| inline

Return rotated vector by "this" quaternion.

## ◆ scale()

template<typename T >

Quat & scale | ( | T | scale,
|  | const Quat< T > & | q
| ) |  |
| inline

this = scalar*q, q need not be distinct object than "this", e.g. q.scale(1.5,q1);

## ◆ setAxisAngle()

template<typename T >

Quat & setAxisAngle | ( | const Vec3< T > & | axis,
|  | T | angle
| ) |  |
| inline

Set "this" quaternion to rotation specified by axis and angle, the axis must be unit vector

## ◆ setIdentity()

template<typename T >

Quat & setIdentity | ( |  | ) |
| inline

Set "this" vector to identity.

## ◆ setZero()

template<typename T >

Quat & setZero | ( |  | ) |
| inline

Set "this" vector to zero.

## ◆ str()

template<typename T >

std::string str | ( |  | ) | const
| inline

Returns
  string representation of Classname

## ◆ sub()

template<typename T >

Quat & sub | ( | const Quat< T > & | q1,
|  | const Quat< T > & | q2
| ) |  |
| inline

this = q1 - q2 "this", q1 and q2 need not be distinct objects, e.g. q.sub(q1,q);

## ◆ unit()

template<typename T >

Quat unit | ( |  | ) | const
| inline

this = normalized this

## ◆ w() [1/2]

template<typename T >

T & w | ( |  | ) |
| inline

## ◆ w() [2/2]

template<typename T >

T w | ( |  | ) | const
| inline

## ◆ write()

template<typename T >

void write | ( | std::ostream & | os | ) | const
| inline

## ◆ x() [1/2]

template<typename T >

T & x | ( |  | ) |
| inline

Reference to the component, e.g. q.x() = 4.5f;.

## ◆ x() [2/2]

template<typename T >

T x | ( |  | ) | const
| inline

Get the component, e.g. float f = q.w();.

## ◆ y() [1/2]

template<typename T >

T & y | ( |  | ) |
| inline

## ◆ y() [2/2]

template<typename T >

T y | ( |  | ) | const
| inline

## ◆ z() [1/2]

template<typename T >

T & z | ( |  | ) |
| inline

## ◆ z() [2/2]

template<typename T >

T z | ( |  | ) | const
| inline

## ◆ zero()

template<typename T >

static Quat zero | ( |  | ) |
| inline static

Predefined constants, e.g. Quat q = Quat::identity();.

## Friends And Related Symbol Documentation

## ◆ operator<<

template<typename T >

std::ostream & operator<< | ( | std::ostream & | stream,
|  | const Quat< T > & | q
| ) |  |
| friend

Output to the stream, e.g. std::cout << q << std::endl;.

## ◆ slerp

template<typename T >

Quat slerp | ( | const Quat< T > & | q1,
|  | const Quat< T > & | q2,
|  | T | t,
|  | T | tolerance
| ) |  |
| friend

## Member Data Documentation

## ◆ mm

template<typename T >

T mm[4]
| protected

## ◆ size

template<typename T >

const int size = 4
| static