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.
/*
** 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);
Methods¶
Methods in detail¶
Construct from euler angles
Construct from Mat33_i
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)
clone method
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
Returns the angle of this quaternion (in radians)
Returns the X axis of this quaternion
Returns the Y axis of this quaternion
Returns the Z axis of this quaternion
Hash for this value
Returns a inverse quaternion of this one
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
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
Returns this quaternion as a 3x3 rotation matrix
Returns a unit quaternion of this one
Returns a unit quaternion of this one, no error reported if cannot be made unit