Quat_i (struct)

The Quat_i represents a 3D rotation as a quaternion. Quaternions are used within the Xfo type. A Quat_i can be converted to and from Mat33_i as well as Euler_i types.

参考

Xfo, Euler_i, Mat33_i

/*
** Example: Quat_i
*/

// create several quaternions
Quat_i q0, q1, q2, q3, q4;
q0 = Quat_i(Vec3_i(1.0, 0.0, 0.0), 0.0);
q1.setFromEuler_i(Euler_i(PI, 0.0, 0.0));
q2.setFromDirectionAndUpvector(Vec3_i(1.0, 0.0, 0.0), Vec3_i(0.0, 1.0, 0.0));
q3.setFrom2Vectors(Vec3_i(1.0, 0.0, 0.0), Vec3_i(1.0, 1.0, 0.0));
q4.setFromAxisAndAngle(Vec3_i(0.0, 1.0, 0.0), HALF_PI);

Quat_i Quat_i Quat_i

Members

Vec3_i v  
SInt32 w  

Methods

  Quat_i ( in Euler_i e )
  Quat_i ( in Mat33_i mat )
  Quat_i ( in Quat_i other )
  Quat_i ( in SInt32 w, in Vec3_i v )
  Quat_i ( in SInt32 x, in SInt32 y, in SInt32 z, in SInt32 w )
  Quat_i ( in Vec3_i v, in SInt32 w )
  Quat_i ()
Quat_i add ? ( in Quat_i other )
  alignWith ! ( in Quat_i other )
Boolean almostEqual ? ( in Quat_i other )
Boolean almostEqual ? ( in Quat_i other, in SInt32 precision )
Quat_i clone ? ()
Quat_i conjugate ? ()
Quat_i divide ? ( in Quat_i other )
Quat_i divideSInt32 ? ( in SInt32 other )
SInt32 dot ? ( in Quat_i other )
Boolean equal ? ( in Quat_i other )
  get ? ( io Float32 v<> )
  get ? ( io Float32 v<>, in UInt32 o )
  get ? ( io Float32 v[] )
  get ? ( io Float32 v[], in UInt32 o )
  get ? ( io Float64 v<> )
  get ? ( io Float64 v<>, in UInt32 o )
  get ? ( io Float64 v[] )
  get ? ( io Float64 v[], in UInt32 o )
SInt32 getAngle ? ()
Vec3_i getXaxis ? ()
Vec3_i getYaxis ? ()
Vec3_i getZaxis ? ()
UInt32 hash ? ()
Quat_i inverse ? ()
SInt32 length ? ()
SInt32 lengthSquared ? ()
Quat_i linearInterpolate ? ( in Quat_i other, in SInt32 t )
  mirror ! ( in Integer axisIndex )
Quat_i multiply ? ( in Quat_i other )
Quat_i multiplySInt32 ? ( in SInt32 other )
Vec3_i rotateVector ? ( in Vec3_i v )
  set ! ( in Float32 v<> )
  set ! ( in Float32 v<>, in UInt32 o )
  set ! ( in Float64 v<> )
  set ! ( in Float64 v<>, in UInt32 o )
  set ! ( in SInt32 w, in Vec3_i v )
  set ! ( in SInt32 x, in SInt32 y, in SInt32 z, in SInt32 w )
  set ! ( in Vec3_i v, in SInt32 w )
Quat_i setFrom2Vectors ! ( in Vec3_i sourceDirVec, in Vec3_i destDirVec )
Quat_i setFrom2Vectors ! ( in Vec3_i sourceDirVec, in Vec3_i destDirVec, in Boolean arbitraryIfAmbiguous )
Quat_i setFromAxisAndAngle ! ( in Vec3_i axis, in SInt32 angle )
Quat_i setFromDirectionAndUpvector ! ( in Vec3_i direction, in Vec3_i upvector )
Quat_i setFromEuler_i ! ( in Euler_i e )
Quat_i setFromEuler_iAngles ! ( in SInt32 eulerX, in SInt32 eulerY, in SInt32 eulerZ )
Quat_i setFromEuler_iAngles ! ( in SInt32 eulerX, in SInt32 eulerY, in SInt32 eulerZ, in RotationOrder ro )
Quat_i setFromEuler_iAngles ! ( in Vec3_i angles )
Quat_i setFromEuler_iAngles ! ( in Vec3_i angles, in RotationOrder ro )
Quat_i setFromMat33_i ! ( in Mat33_i mat )
  setIdentity ! ()
SInt32 setUnit ! ()
Quat_i sphericalLinearInterpolate ? ( in Quat_i q2, in SInt32 t )
Quat_i subtract ? ( in Quat_i other )
Euler_i toEuler_i ? ( in RotationOrder rotationOrder )
Vec3_i toEuler_iAngles ? ( in RotationOrder order )
Vec3_i toEuler_iAngles ? ()
Mat33_i toMat33_i ? ()
Quat_i unit ? ()
Quat_i unit_safe ? ()

Operators

Quat_i = ( Param other )

Methods in detail

Quat_i ( in Euler_i e )

Construct from euler angles


Quat_i ( in Mat33_i mat )

Construct from Mat33_i


Quat_i ( in Quat_i other )

copy constructor


Quat_i ( in SInt32 w, in Vec3_i v )

Construct from scalar and vector


Quat_i ( in SInt32 x, in SInt32 y, in SInt32 z, in SInt32 w )

Construct from scalars


Quat_i ( in Vec3_i v, in SInt32 w )

Construct from vector and scalar


Quat_i ()

Default constructor - set to identity


Quat_i Quat_i.add? ( in Quat_i other )

Overload method for the add operator


Quat_i.alignWith! ( in Quat_i other )

Aligns this quaternion with another one ensuring that the delta between the Quaternion values is the shortest path over the hypersphere.


Boolean Quat_i.almostEqual? ( in Quat_i other )

Returns true if this quaternion is almost equal to another one (using a default precision)


Boolean Quat_i.almostEqual? ( in Quat_i other, in SInt32 precision )

Returns true if this quaternion is almost equal to another one (given a precision)


Quat_i Quat_i.clone? ()

clone method


Quat_i Quat_i.conjugate? ()

Returns the conjugate of this quaternion


Quat_i Quat_i.divide? ( in Quat_i other )

Overload method for the divide operator


Quat_i Quat_i.divideSInt32? ( in SInt32 other )

Returns the division of this quaternion and a scalar


SInt32 Quat_i.dot? ( in Quat_i other )

Returns the dot product of this quaternion and another one


Boolean Quat_i.equal? ( in Quat_i other )

Returns true if this quaternion is equal to another one


Quat_i.get? ( io Float32 v<> )

Getter as external float32 array


Quat_i.get? ( io Float32 v<>, in UInt32 o )

Getter as external float32 array and an offset


Quat_i.get? ( io Float32 v[] )

Getter as float32 array


Quat_i.get? ( io Float32 v[], in UInt32 o )

Getter as float32 array and an offset


Quat_i.get? ( io Float64 v<> )

Getter as external float64 array


Quat_i.get? ( io Float64 v<>, in UInt32 o )

Getter as external float64 array and an offset


Quat_i.get? ( io Float64 v[] )

Getter as float64 array


Quat_i.get? ( io Float64 v[], in UInt32 o )

Getter as float64 array and an offset


SInt32 Quat_i.getAngle? ()

Returns the angle of this quaternion (in radians)


Vec3_i Quat_i.getXaxis? ()

Returns the X axis of this quaternion


Vec3_i Quat_i.getYaxis? ()

Returns the Y axis of this quaternion


Vec3_i Quat_i.getZaxis? ()

Returns the Z axis of this quaternion


UInt32 Quat_i.hash? ()

Hash for this value


Quat_i Quat_i.inverse? ()

Returns a inverse quaternion of this one


SInt32 Quat_i.length? ()

Returns the length of this quaternion


SInt32 Quat_i.lengthSquared? ()

Returns the squared length of this quaternion


Quat_i Quat_i.linearInterpolate? ( in Quat_i other, in SInt32 t )

Interpolates two quaternions lineally (lerp) with a given blend value (0.0 to 1.0).

注釈

The interpolation of the 2 quaternions will result acceleration and deceleration. Use Quat_i.sphericalLinearInterpolate for an interpolation that does not introduce acceleration.


Quat_i.mirror! ( in Integer axisIndex )

Reflects this Quaternion according to the axis provided.

axisIndex An integer with value of 0 for the X axis, 1 for the Y axis, and 2 for the Z axis.


Quat_i Quat_i.multiply? ( in Quat_i other )

Overload method for the multiply operator


Quat_i Quat_i.multiplySInt32? ( in SInt32 other )

Returns the product of this quaternion and a scalar


Vec3_i Quat_i.rotateVector? ( in Vec3_i v )

Rotates a vector by this quaterion. Don’t forget to normalize the quaternion unless you want axial translation as well as rotation.


Quat_i.set! ( in Float32 v<> )

Setter from (standard/external) float32 array


Quat_i.set! ( in Float32 v<>, in UInt32 o )

Setter from (standard/external) float32 array and an offset


Quat_i.set! ( in Float64 v<> )

Setter from (standard/external) float64 array


Quat_i.set! ( in Float64 v<>, in UInt32 o )

Setter from (standard/external) float64 array and an offset


Quat_i.set! ( in SInt32 w, in Vec3_i v )

Setter from scalar and vector


Quat_i.set! ( in SInt32 x, in SInt32 y, in SInt32 z, in SInt32 w )

Sets each component with a single scalar value.


Quat_i.set! ( in Vec3_i v, in SInt32 w )

Setter from vector and scalar


Quat_i Quat_i.setFrom2Vectors! ( in Vec3_i sourceDirVec, in Vec3_i destDirVec )

Overload for previous setFrom2Vectors method, avoid arbitrary rotations.


Quat_i Quat_i.setFrom2Vectors! ( in Vec3_i sourceDirVec, in Vec3_i destDirVec, in Boolean arbitraryIfAmbiguous )

Set the quaternion to the rotation required to rotate the source vector to the destination vector Function taken from the ‘Game Programming Gems’ article ‘The Shortest Arc Quaternion’ by Stan Melax Both vectors must be units.


Quat_i Quat_i.setFromAxisAndAngle! ( in Vec3_i axis, in SInt32 angle )

Set this quat to a rotation defined by an axis and an angle (in radians)


Quat_i Quat_i.setFromDirectionAndUpvector! ( in Vec3_i direction, in Vec3_i upvector )

Set the quat to represent the direction as the Z axis and the upvector pointing along the XY plane.


Quat_i Quat_i.setFromEuler_i! ( in Euler_i e )

Set this quat from a euler rotation


Quat_i Quat_i.setFromEuler_iAngles! ( in SInt32 eulerX, in SInt32 eulerY, in SInt32 eulerZ )

Set this quat to a given angles vector (in radians) using the default XYZ rotation order


Quat_i Quat_i.setFromEuler_iAngles! ( in SInt32 eulerX, in SInt32 eulerY, in SInt32 eulerZ, in RotationOrder ro )

Set this quat to a given angles vector (in radians) and a rotation order


Quat_i Quat_i.setFromEuler_iAngles! ( in Vec3_i angles )

Set this quat to a given angles vector (in radians) using the default XYZ rotation order


Quat_i Quat_i.setFromEuler_iAngles! ( in Vec3_i angles, in RotationOrder ro )

Set this quat to a given angles vector (in radians) and a rotation order


Quat_i Quat_i.setFromMat33_i! ( in Mat33_i mat )

Set this quat to the rotation described by a 3x3 rotation matrix


Quat_i.setIdentity! ()

Set this quat to the identity


SInt32 Quat_i.setUnit! ()

Sets this quaternion to a unit quaternion and returns the previous length


Quat_i Quat_i.sphericalLinearInterpolate? ( in Quat_i q2, in SInt32 t )

interpolates two quaternions spherically (slerp) given a scalar blend value (0.0 to 1.0).

注釈

this and q2 should be unit Quaternions


Quat_i Quat_i.subtract? ( in Quat_i other )

Overload method for the subtract operator


Euler_i Quat_i.toEuler_i? ( in RotationOrder rotationOrder )

Returns this quaternion as a Euler_i rotation giving a rotation order


Vec3_i Quat_i.toEuler_iAngles? ( in RotationOrder order )

Returns this quaternion as a Euler_i angles using the rotationorder XYZ


Vec3_i Quat_i.toEuler_iAngles? ()

Returns this quaternion as a Euler_i angles using the rotationorder XYZ


Mat33_i Quat_i.toMat33_i? ()

Returns this quaternion as a 3x3 rotation matrix


Quat_i Quat_i.unit? ()

Returns a unit quaternion of this one


Quat_i Quat_i.unit_safe? ()

Returns a unit quaternion of this one, no error reported if cannot be made unit

Operators in detail

Quat_i = ( Param other )

Adds another quaternion to this one