cocos2d-x  3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Quaternion Class Reference

Defines a 4-element quaternion that represents the orientation of an object in space. More...

#include <Quaternion.h>

Public Member Functions

 Quaternion ()
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion ()
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion ()
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion (float xx, float yy, float zz, float ww)
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion ( var xx, var yy, var zz, var ww)
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion ( local xx, local yy, local zz, local ww)
 Constructs a quaternion initialized to (0, 0, 0, 1). More...
 
 Quaternion (float *array)
 Constructs a new quaternion from the values in the specified array. More...
 
 Quaternion ( var array)
 Constructs a new quaternion from the values in the specified array. More...
 
 Quaternion ( local array)
 Constructs a new quaternion from the values in the specified array. More...
 
 Quaternion (const Mat4 &m)
 Constructs a quaternion equal to the rotational part of the specified matrix. More...
 
 Quaternion (const Vec3 &axis, float angle)
 Constructs a quaternion equal to the rotation from the specified axis and angle. More...
 
 Quaternion (const Quaternion &copy)
 Constructs a new quaternion that is a copy of the specified one. More...
 
 ~Quaternion ()
 Destructor. More...
 
bool isIdentity () const
 Determines if this quaternion is equal to the identity quaternion. More...
 
var isIdentity ()
 Determines if this quaternion is equal to the identity quaternion. More...
 
local isIdentity ()
 Determines if this quaternion is equal to the identity quaternion. More...
 
bool isZero () const
 Determines if this quaternion is all zeros. More...
 
void conjugate ()
 Sets this quaternion to the conjugate of itself. More...
 
var conjugate ()
 Sets this quaternion to the conjugate of itself. More...
 
local conjugate ()
 Sets this quaternion to the conjugate of itself. More...
 
Quaternion getConjugated () const
 Gets the conjugate of this quaternion in dst. More...
 
local getConjugated ()
 Gets the conjugate of this quaternion in dst. More...
 
bool inverse ()
 Sets this quaternion to the inverse of itself. More...
 
var inverse ()
 Sets this quaternion to the inverse of itself. More...
 
local inverse ()
 Sets this quaternion to the inverse of itself. More...
 
Quaternion getInversed () const
 Gets the inverse of this quaternion in dst. More...
 
void multiply (const Quaternion &q)
 Multiplies this quaternion by the specified one and stores the result in this quaternion. More...
 
void normalize ()
 Normalizes this quaternion to have unit length. More...
 
Quaternion getNormalized () const
 Normalizes this quaternion and stores the result in dst. More...
 
local getNormalized ()
 Normalizes this quaternion and stores the result in dst. More...
 
void set (float xx, float yy, float zz, float ww)
 Sets the elements of the quaternion to the specified values. More...
 
var set ( var xx, var yy, var zz, var ww)
 Sets the elements of the quaternion to the specified values. More...
 
local set ( local xx, local yy, local zz, local ww)
 Sets the elements of the quaternion to the specified values. More...
 
void set (float *array)
 Sets the elements of the quaternion from the values in the specified array. More...
 
void set (const Mat4 &m)
 Sets the quaternion equal to the rotational part of the specified matrix. More...
 
void set (const Vec3 &axis, float angle)
 Sets the quaternion equal to the rotation from the specified axis and angle. More...
 
var set ( var axis, var angle)
 Sets the quaternion equal to the rotation from the specified axis and angle. More...
 
local set ( local axis, local angle)
 Sets the quaternion equal to the rotation from the specified axis and angle. More...
 
void set (const Quaternion &q)
 Sets the elements of this quaternion to a copy of the specified quaternion. More...
 
void setIdentity ()
 Sets this quaternion to be equal to the identity quaternion. More...
 
var setIdentity ()
 Sets this quaternion to be equal to the identity quaternion. More...
 
float toAxisAngle (Vec3 *e) const
 Converts this Quaternion4f to axis-angle notation. More...
 
var toAxisAngle ( var e)
 Converts this Quaternion4f to axis-angle notation. More...
 
local toAxisAngle ( local e)
 Converts this Quaternion4f to axis-angle notation. More...
 
const Quaternion operator* (const Quaternion &q) const
 Calculates the quaternion product of this quaternion with the given quaternion. More...
 
Quaternionoperator*= (const Quaternion &q)
 Multiplies this quaternion with the given quaternion. More...
 

Static Public Member Functions

static const Quaternionidentity ()
 Returns the identity quaternion. More...
 
local identity ()
 Returns the identity quaternion. More...
 
static const Quaternionzero ()
 Returns the quaternion with all zeros. More...
 
local zero ()
 Returns the quaternion with all zeros. More...
 
static void createFromRotationMatrix (const Mat4 &m, Quaternion *dst)
 Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst. More...
 
var createFromRotationMatrix ( var m, var dst)
 Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst. More...
 
local createFromRotationMatrix ( local m, local dst)
 Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst. More...
 
static void createFromAxisAngle (const Vec3 &axis, float angle, Quaternion *dst)
 Creates this quaternion equal to the rotation from the specified axis and angle and stores the result in dst. More...
 
local createFromAxisAngle ( local axis, local angle, local dst)
 Creates this quaternion equal to the rotation from the specified axis and angle and stores the result in dst. More...
 
static void multiply (const Quaternion &q1, const Quaternion &q2, Quaternion *dst)
 Multiplies the specified quaternions and stores the result in dst. More...
 
static void lerp (const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst)
 Interpolates between two quaternions using linear interpolation. More...
 
local lerp ( local q1, local q2, local t, local dst)
 Interpolates between two quaternions using linear interpolation. More...
 
static void slerp (const Quaternion &q1, const Quaternion &q2, float t, Quaternion *dst)
 Interpolates between two quaternions using spherical linear interpolation. More...
 
local slerp ( local q1, local q2, local t, local dst)
 Interpolates between two quaternions using spherical linear interpolation. More...
 
static void squad (const Quaternion &q1, const Quaternion &q2, const Quaternion &s1, const Quaternion &s2, float t, Quaternion *dst)
 Interpolates over a series of quaternions using spherical spline interpolation. More...
 
local squad ( local q1, local q2, local s1, local s2, local t, local dst)
 Interpolates over a series of quaternions using spherical spline interpolation. More...
 

Public Attributes

float x
 The x-value of the quaternion's vector component. More...
 
var x
 The x-value of the quaternion's vector component. More...
 
local x
 The x-value of the quaternion's vector component. More...
 
float y
 The y-value of the quaternion's vector component. More...
 
var y
 The y-value of the quaternion's vector component. More...
 
local y
 The y-value of the quaternion's vector component. More...
 
float z
 The z-value of the quaternion's vector component. More...
 
var z
 The z-value of the quaternion's vector component. More...
 
local z
 The z-value of the quaternion's vector component. More...
 
float w
 The scalar component of the quaternion. More...
 
var w
 The scalar component of the quaternion. More...
 
local w
 The scalar component of the quaternion. More...
 

Friends

class Curve
class Transform

Detailed Description

Defines a 4-element quaternion that represents the orientation of an object in space.

Quaternions are typically used as a replacement for euler angles and rotation matrices as a way to achieve smooth interpolation and avoid gimbal lock.

Note that this quaternion class does not automatically keep the quaternion normalized. Therefore, care must be taken to normalize the quaternion when necessary, by calling the normalize method. This class provides three methods for doing quaternion interpolation: lerp, slerp, and squad.

lerp (linear interpolation): the interpolation curve gives a straight line in quaternion space. It is simple and fast to compute. The only problem is that it does not provide constant angular velocity. Note that a constant velocity is not necessarily a requirement for a curve; slerp (spherical linear interpolation): the interpolation curve forms a great arc on the quaternion unit sphere. Slerp provides constant angular velocity; squad (spherical spline interpolation): interpolating between a series of rotations using slerp leads to the following problems:

  • the curve is not smooth at the control points;
  • the angular velocity is not constant;
  • the angular velocity is not continuous at the control points.

Since squad is continuously differentiable, it remedies the first and third problems mentioned above. The slerp method provided here is intended for interpolation of principal rotations. It treats +q and -q as the same principal rotation and is at liberty to use the negative of either input. The resulting path is always the shorter arc.

The lerp method provided here interpolates strictly in quaternion space. Note that the resulting path may pass through the origin if interpolating between a quaternion and its exact negative.

As an example, consider the following quaternions:

q1 = (0.6, 0.8, 0.0, 0.0), q2 = (0.0, 0.6, 0.8, 0.0), q3 = (0.6, 0.0, 0.8, 0.0), and q4 = (-0.8, 0.0, -0.6, 0.0). For the point p = (1.0, 1.0, 1.0), the following figures show the trajectories of p using lerp, slerp, and squad.

Constructor & Destructor Documentation

Constructs a quaternion initialized to (0, 0, 0, 1).

var Quaternion ( )

Constructs a quaternion initialized to (0, 0, 0, 1).

local Quaternion ( )

Constructs a quaternion initialized to (0, 0, 0, 1).

Quaternion ( float  xx,
float  yy,
float  zz,
float  ww 
)

Constructs a quaternion initialized to (0, 0, 0, 1).

Parameters
xxThe x component of the quaternion.
yyThe y component of the quaternion.
zzThe z component of the quaternion.
wwThe w component of the quaternion.
var Quaternion ( var  xx,
var  yy,
var  zz,
var  ww 
)

Constructs a quaternion initialized to (0, 0, 0, 1).

Parameters
xxThe x component of the quaternion.
yyThe y component of the quaternion.
zzThe z component of the quaternion.
wwThe w component of the quaternion.
local Quaternion ( local  xx,
local  yy,
local  zz,
local  ww 
)

Constructs a quaternion initialized to (0, 0, 0, 1).

Parameters
xxThe x component of the quaternion.
yyThe y component of the quaternion.
zzThe z component of the quaternion.
wwThe w component of the quaternion.
Quaternion ( float *  array)

Constructs a new quaternion from the values in the specified array.

Parameters
arrayThe values for the new quaternion.
var Quaternion ( var  array)

Constructs a new quaternion from the values in the specified array.

Parameters
arrayThe values for the new quaternion.
local Quaternion ( local  array)

Constructs a new quaternion from the values in the specified array.

Parameters
arrayThe values for the new quaternion.
Quaternion ( const Mat4 m)

Constructs a quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
var Quaternion ( var  m)

Constructs a quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
local Quaternion ( local  m)

Constructs a quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
Quaternion ( const Vec3 axis,
float  angle 
)

Constructs a quaternion equal to the rotation from the specified axis and angle.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
var Quaternion ( var  axis,
var  angle 
)

Constructs a quaternion equal to the rotation from the specified axis and angle.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
local Quaternion ( local  axis,
local  angle 
)

Constructs a quaternion equal to the rotation from the specified axis and angle.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
Quaternion ( const Quaternion copy)

Constructs a new quaternion that is a copy of the specified one.

Parameters
copyThe quaternion to copy.
var Quaternion ( var  copy)

Constructs a new quaternion that is a copy of the specified one.

Parameters
copyThe quaternion to copy.
local Quaternion ( local  copy)

Constructs a new quaternion that is a copy of the specified one.

Parameters
copyThe quaternion to copy.
~Quaternion ( )

Destructor.

var ~Quaternion ( )

Destructor.

local ~Quaternion ( )

Destructor.

Member Function Documentation

void conjugate ( )

Sets this quaternion to the conjugate of itself.

var conjugate ( )

Sets this quaternion to the conjugate of itself.

local conjugate ( )

Sets this quaternion to the conjugate of itself.

static void createFromAxisAngle ( const Vec3 axis,
float  angle,
Quaternion dst 
)
static

Creates this quaternion equal to the rotation from the specified axis and angle and stores the result in dst.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
dstA quaternion to store the conjugate in.
var createFromAxisAngle ( var  axis,
var  angle,
var  dst 
)
static

Creates this quaternion equal to the rotation from the specified axis and angle and stores the result in dst.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
dstA quaternion to store the conjugate in.
local createFromAxisAngle ( local  axis,
local  angle,
local  dst 
)
static

Creates this quaternion equal to the rotation from the specified axis and angle and stores the result in dst.

Parameters
axisA vector describing the axis of rotation.
angleThe angle of rotation (in radians).
dstA quaternion to store the conjugate in.
static void
createFromRotationMatrix
( const Mat4 m,
Quaternion dst 
)
static

Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst.

Parameters
mThe matrix.
dstA quaternion to store the conjugate in.
var createFromRotationMatrix ( var  m,
var  dst 
)
static

Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst.

Parameters
mThe matrix.
dstA quaternion to store the conjugate in.
local createFromRotationMatrix ( local  m,
local  dst 
)
static

Creates a quaternion equal to the rotational part of the specified matrix and stores the result in dst.

Parameters
mThe matrix.
dstA quaternion to store the conjugate in.
Quaternion getConjugated ( ) const

Gets the conjugate of this quaternion in dst.

Parameters
dstA quaternion to store the conjugate in.
var getConjugated ( )

Gets the conjugate of this quaternion in dst.

Parameters
dstA quaternion to store the conjugate in.
local getConjugated ( )

Gets the conjugate of this quaternion in dst.

Parameters
dstA quaternion to store the conjugate in.
Quaternion getInversed ( ) const

Gets the inverse of this quaternion in dst.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Parameters
dstA quaternion to store the inverse in.
Returns
true if the inverse can be computed, false otherwise.
var getInversed ( )

Gets the inverse of this quaternion in dst.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Parameters
dstA quaternion to store the inverse in.
Returns
true if the inverse can be computed, false otherwise.
local getInversed ( )

Gets the inverse of this quaternion in dst.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Parameters
dstA quaternion to store the inverse in.
Returns
true if the inverse can be computed, false otherwise.
Quaternion getNormalized ( ) const

Normalizes this quaternion and stores the result in dst.

If the quaternion already has unit length or if the length of the quaternion is zero, this method simply copies this vector into dst.

Parameters
dstA quaternion to store the result in.
var getNormalized ( )

Normalizes this quaternion and stores the result in dst.

If the quaternion already has unit length or if the length of the quaternion is zero, this method simply copies this vector into dst.

Parameters
dstA quaternion to store the result in.
local getNormalized ( )

Normalizes this quaternion and stores the result in dst.

If the quaternion already has unit length or if the length of the quaternion is zero, this method simply copies this vector into dst.

Parameters
dstA quaternion to store the result in.
static const Quaternion& identity ( )
static

Returns the identity quaternion.

Returns
The identity quaternion.
var identity ( )
static

Returns the identity quaternion.

Returns
The identity quaternion.
local identity ( )
static

Returns the identity quaternion.

Returns
The identity quaternion.
bool inverse ( )

Sets this quaternion to the inverse of itself.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Returns
true if the inverse can be computed, false otherwise.
var inverse ( )

Sets this quaternion to the inverse of itself.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Returns
true if the inverse can be computed, false otherwise.
local inverse ( )

Sets this quaternion to the inverse of itself.

Note that the inverse of a quaternion is equal to its conjugate when the quaternion is unit-length. For this reason, it is more efficient to use the conjugate method directly when you know your quaternion is already unit-length.

Returns
true if the inverse can be computed, false otherwise.
bool isIdentity ( ) const

Determines if this quaternion is equal to the identity quaternion.

Returns
true if it is the identity quaternion, false otherwise.
var isIdentity ( )

Determines if this quaternion is equal to the identity quaternion.

Returns
true if it is the identity quaternion, false otherwise.
local isIdentity ( )

Determines if this quaternion is equal to the identity quaternion.

Returns
true if it is the identity quaternion, false otherwise.
bool isZero ( ) const

Determines if this quaternion is all zeros.

Returns
true if this quaternion is all zeros, false otherwise.
var isZero ( )

Determines if this quaternion is all zeros.

Returns
true if this quaternion is all zeros, false otherwise.
local isZero ( )

Determines if this quaternion is all zeros.

Returns
true if this quaternion is all zeros, false otherwise.
static void lerp ( const Quaternion q1,
const Quaternion q2,
float  t,
Quaternion dst 
)
static

Interpolates between two quaternions using linear interpolation.

The interpolation curve for linear interpolation between quaternions gives a straight line in quaternion space.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
var lerp ( var  q1,
var  q2,
var  t,
var  dst 
)
static

Interpolates between two quaternions using linear interpolation.

The interpolation curve for linear interpolation between quaternions gives a straight line in quaternion space.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
local lerp ( local  q1,
local  q2,
local  t,
local  dst 
)
static

Interpolates between two quaternions using linear interpolation.

The interpolation curve for linear interpolation between quaternions gives a straight line in quaternion space.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
void multiply ( const Quaternion q)

Multiplies this quaternion by the specified one and stores the result in this quaternion.

Parameters
qThe quaternion to multiply.
var multiply ( var  q)

Multiplies this quaternion by the specified one and stores the result in this quaternion.

Parameters
qThe quaternion to multiply.
local multiply ( local  q)

Multiplies this quaternion by the specified one and stores the result in this quaternion.

Parameters
qThe quaternion to multiply.
static void multiply ( const Quaternion q1,
const Quaternion q2,
Quaternion dst 
)
static

Multiplies the specified quaternions and stores the result in dst.

Parameters
q1The first quaternion.
q2The second quaternion.
dstA quaternion to store the result in.
var multiply ( var  q1,
var  q2,
var  dst 
)
static

Multiplies the specified quaternions and stores the result in dst.

Parameters
q1The first quaternion.
q2The second quaternion.
dstA quaternion to store the result in.
local multiply ( local  q1,
local  q2,
local  dst 
)
static

Multiplies the specified quaternions and stores the result in dst.

Parameters
q1The first quaternion.
q2The second quaternion.
dstA quaternion to store the result in.
void normalize ( )

Normalizes this quaternion to have unit length.

If the quaternion already has unit length or if the length of the quaternion is zero, this method does nothing.

var normalize ( )

Normalizes this quaternion to have unit length.

If the quaternion already has unit length or if the length of the quaternion is zero, this method does nothing.

local normalize ( )

Normalizes this quaternion to have unit length.

If the quaternion already has unit length or if the length of the quaternion is zero, this method does nothing.

const Quaternion operator* ( const Quaternion q) const
inline

Calculates the quaternion product of this quaternion with the given quaternion.

Note: this does not modify this quaternion.

Parameters
qThe quaternion to multiply.
Returns
The quaternion product.
const Quaternion operator* ( var  q)
inline

Calculates the quaternion product of this quaternion with the given quaternion.

Note: this does not modify this quaternion.

Parameters
qThe quaternion to multiply.
Returns
The quaternion product.
const Quaternion operator* ( local  q)
inline

Calculates the quaternion product of this quaternion with the given quaternion.

Note: this does not modify this quaternion.

Parameters
qThe quaternion to multiply.
Returns
The quaternion product.
Quaternion& operator*= ( const Quaternion q)
inline

Multiplies this quaternion with the given quaternion.

Parameters
qThe quaternion to multiply.
Returns
This quaternion, after the multiplication occurs.
Quaternion& operator*= ( var  q)
inline

Multiplies this quaternion with the given quaternion.

Parameters
qThe quaternion to multiply.
Returns
This quaternion, after the multiplication occurs.
Quaternion& operator*= ( local  q)
inline

Multiplies this quaternion with the given quaternion.

Parameters
qThe quaternion to multiply.
Returns
This quaternion, after the multiplication occurs.
void set ( float  xx,
float  yy,
float  zz,
float  ww 
)

Sets the elements of the quaternion to the specified values.

Parameters
xxThe new x-value.
yyThe new y-value.
zzThe new z-value.
wwThe new w-value.
var set ( var  xx,
var  yy,
var  zz,
var  ww 
)

Sets the elements of the quaternion to the specified values.

Parameters
xxThe new x-value.
yyThe new y-value.
zzThe new z-value.
wwThe new w-value.
local set ( local  xx,
local  yy,
local  zz,
local  ww 
)

Sets the elements of the quaternion to the specified values.

Parameters
xxThe new x-value.
yyThe new y-value.
zzThe new z-value.
wwThe new w-value.
void set ( float *  array)

Sets the elements of the quaternion from the values in the specified array.

Parameters
arrayAn array containing the elements of the quaternion in the order x, y, z, w.
var set ( var  array)

Sets the elements of the quaternion from the values in the specified array.

Parameters
arrayAn array containing the elements of the quaternion in the order x, y, z, w.
local set ( local  array)

Sets the elements of the quaternion from the values in the specified array.

Parameters
arrayAn array containing the elements of the quaternion in the order x, y, z, w.
void set ( const Mat4 m)

Sets the quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
var set ( var  m)

Sets the quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
local set ( local  m)

Sets the quaternion equal to the rotational part of the specified matrix.

Parameters
mThe matrix.
void set ( const Vec3 axis,
float  angle 
)

Sets the quaternion equal to the rotation from the specified axis and angle.

Parameters
axisThe axis of rotation.
angleThe angle of rotation (in radians).
var set ( var  axis,
var  angle 
)

Sets the quaternion equal to the rotation from the specified axis and angle.

Parameters
axisThe axis of rotation.
angleThe angle of rotation (in radians).
local set ( local  axis,
local  angle 
)

Sets the quaternion equal to the rotation from the specified axis and angle.

Parameters
axisThe axis of rotation.
angleThe angle of rotation (in radians).
void set ( const Quaternion q)

Sets the elements of this quaternion to a copy of the specified quaternion.

Parameters
qThe quaternion to copy.
var set ( var  q)

Sets the elements of this quaternion to a copy of the specified quaternion.

Parameters
qThe quaternion to copy.
local set ( local  q)

Sets the elements of this quaternion to a copy of the specified quaternion.

Parameters
qThe quaternion to copy.
void setIdentity ( )

Sets this quaternion to be equal to the identity quaternion.

var setIdentity ( )

Sets this quaternion to be equal to the identity quaternion.

local setIdentity ( )

Sets this quaternion to be equal to the identity quaternion.

static void slerp ( const Quaternion q1,
const Quaternion q2,
float  t,
Quaternion dst 
)
static

Interpolates between two quaternions using spherical linear interpolation.

Spherical linear interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be at (or close to) unit length. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
var slerp ( var  q1,
var  q2,
var  t,
var  dst 
)
static

Interpolates between two quaternions using spherical linear interpolation.

Spherical linear interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be at (or close to) unit length. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
local slerp ( local  q1,
local  q2,
local  t,
local  dst 
)
static

Interpolates between two quaternions using spherical linear interpolation.

Spherical linear interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be at (or close to) unit length. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
tThe interpolation coefficient.
dstA quaternion to store the result in.
static void squad ( const Quaternion q1,
const Quaternion q2,
const Quaternion s1,
const Quaternion s2,
float  t,
Quaternion dst 
)
static

Interpolates over a series of quaternions using spherical spline interpolation.

Spherical spline interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be unit. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
s1The first control point.
s2The second control point.
tThe interpolation coefficient.
dstA quaternion to store the result in.
var squad ( var  q1,
var  q2,
var  s1,
var  s2,
var  t,
var  dst 
)
static

Interpolates over a series of quaternions using spherical spline interpolation.

Spherical spline interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be unit. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
s1The first control point.
s2The second control point.
tThe interpolation coefficient.
dstA quaternion to store the result in.
local squad ( local  q1,
local  q2,
local  s1,
local  s2,
local  t,
local  dst 
)
static

Interpolates over a series of quaternions using spherical spline interpolation.

Spherical spline interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Note: For accurate interpolation, the input quaternions must be unit. This method does not automatically normalize the input quaternions, so it is up to the caller to ensure they call normalize beforehand, if necessary.

Parameters
q1The first quaternion.
q2The second quaternion.
s1The first control point.
s2The second control point.
tThe interpolation coefficient.
dstA quaternion to store the result in.
float toAxisAngle ( Vec3 e) const

Converts this Quaternion4f to axis-angle notation.

The axis is normalized.

Parameters
eThe Vec3f which stores the axis.
Returns
The angle (in radians).
var toAxisAngle ( var  e)

Converts this Quaternion4f to axis-angle notation.

The axis is normalized.

Parameters
eThe Vec3f which stores the axis.
Returns
The angle (in radians).
local toAxisAngle ( local  e)

Converts this Quaternion4f to axis-angle notation.

The axis is normalized.

Parameters
eThe Vec3f which stores the axis.
Returns
The angle (in radians).
static const Quaternion& zero ( )
static

Returns the quaternion with all zeros.

Returns
The quaternion.
var zero ( )
static

Returns the quaternion with all zeros.

Returns
The quaternion.
local zero ( )
static

Returns the quaternion with all zeros.

Returns
The quaternion.

Friends And Related Function Documentation

friend class Curve
friend
friend class Transform
friend
var Transform
friend
local Transform
friend

Member Data Documentation

float w

The scalar component of the quaternion.

var w

The scalar component of the quaternion.

local w

The scalar component of the quaternion.

float x

The x-value of the quaternion's vector component.

var x

The x-value of the quaternion's vector component.

local x

The x-value of the quaternion's vector component.

float y

The y-value of the quaternion's vector component.

var y

The y-value of the quaternion's vector component.

local y

The y-value of the quaternion's vector component.

float z

The z-value of the quaternion's vector component.

var z

The z-value of the quaternion's vector component.

local z

The z-value of the quaternion's vector component.


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