Quat_d (struct)¶
The Quat_d represents a 3D rotation as a quaternion. Quaternions are used within the Xfo type. A Quat_d can be converted to and from Mat33_d as well as Euler_d types.
/*
** Example: Quat_d
*/
// create several quaternions
Quat_d q0, q1, q2, q3, q4;
q0 = Quat_d(Vec3_d(1.0, 0.0, 0.0), 0.0);
q1.setFromEuler_d(Euler_d(PI, 0.0, 0.0));
q2.setFromDirectionAndUpvector(Vec3_d(1.0, 0.0, 0.0), Vec3_d(0.0, 1.0, 0.0));
q3.setFrom2Vectors(Vec3_d(1.0, 0.0, 0.0), Vec3_d(1.0, 1.0, 0.0));
q4.setFromAxisAndAngle(Vec3_d(0.0, 1.0, 0.0), HALF_PI);
Methods¶
Methods in detail¶
Construct from euler angles
Quat_d ( in Float64 w, in Vec3_d v )
Construct from scalar and vector
Quat_d ( in Float64 x, in Float64 y, in Float64 z, in Float64 w )
Construct from scalars
Construct from Mat33_d
copy constructor
Quat_d ( in Vec3_d v, in Float64 w )
Construct from vector and scalar
Quat_d ()
Default constructor - set to identity
Quat_d Quat_d.add? ( in Quat_d other )
Overload method for the add operator
Quat_d.alignWith! ( in Quat_d other )
Aligns this quaternion with another one ensuring that the delta between the Quaternion values is the shortest path over the hypersphere.
Boolean Quat_d.almostEqual? ( in Quat_d other )
Returns true if this quaternion is almost equal to another one (using a default precision)
Boolean Quat_d.almostEqual? ( in Quat_d other, in Float64 precision )
Returns true if this quaternion is almost equal to another one (given a precision)
clone method
Returns the conjugate of this quaternion
Quat_d Quat_d.divide? ( in Quat_d other )
Overload method for the divide operator
Quat_d Quat_d.divideFloat64? ( in Float64 other )
Returns the division of this quaternion and a scalar
Float64 Quat_d.dot? ( in Quat_d other )
Returns the dot product of this quaternion and another one
Boolean Quat_d.equal? ( in Quat_d other )
Returns true if this quaternion is equal to another one
Quat_d.get? ( io Float32 v<> )
Getter as external float32 array
Quat_d.get? ( io Float32 v<>, in UInt32 o )
Getter as external float32 array and an offset
Quat_d.get? ( io Float32 v[] )
Getter as float32 array
Quat_d.get? ( io Float32 v[], in UInt32 o )
Getter as float32 array and an offset
Quat_d.get? ( io Float64 v<> )
Getter as external float64 array
Quat_d.get? ( io Float64 v<>, in UInt32 o )
Getter as external float64 array and an offset
Quat_d.get? ( io Float64 v[] )
Getter as float64 array
Quat_d.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
Float64 Quat_d.lengthSquared? ()
Returns the squared length of this quaternion
Quat_d Quat_d.linearInterpolate? ( in Quat_d other, in Float64 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_d.sphericalLinearInterpolate for an interpolation that does not introduce acceleration.
Quat_d.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_d Quat_d.multiply? ( in Quat_d other )
Overload method for the multiply operator
Quat_d Quat_d.multiplyFloat64? ( in Float64 other )
Returns the product of this quaternion and a scalar
Vec3_d Quat_d.rotateVector? ( in Vec3_d v )
Rotates a vector by this quaterion. Don’t forget to normalize the quaternion unless you want axial translation as well as rotation.
Quat_d.set! ( in Float32 v<> )
Setter from (standard/external) float32 array
Quat_d.set! ( in Float32 v<>, in UInt32 o )
Setter from (standard/external) float32 array and an offset
Quat_d.set! ( in Float64 v<> )
Setter from (standard/external) float64 array
Quat_d.set! ( in Float64 v<>, in UInt32 o )
Setter from (standard/external) float64 array and an offset
Quat_d.set! ( in Float64 w, in Vec3_d v )
Setter from scalar and vector
Quat_d.set! ( in Float64 x, in Float64 y, in Float64 z, in Float64 w )
Sets each component with a single scalar value.
Quat_d.set! ( in Vec3_d v, in Float64 w )
Setter from vector and scalar
Quat_d Quat_d.setFrom2Vectors! ( in Vec3_d sourceDirVec, in Vec3_d destDirVec )
Overload for previous setFrom2Vectors method, avoid arbitrary rotations.
Quat_d Quat_d.setFrom2Vectors! ( in Vec3_d sourceDirVec, in Vec3_d 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_d Quat_d.setFromAxisAndAngle! ( in Vec3_d axis, in Float64 angle )
Set this quat to a rotation defined by an axis and an angle (in radians)
Quat_d Quat_d.setFromDirectionAndUpvector! ( in Vec3_d direction, in Vec3_d upvector )
Set the quat to represent the direction as the Z axis and the upvector pointing along the XY plane.
Quat_d Quat_d.setFromEuler_d! ( in Euler_d e )
Set this quat from a euler rotation
Quat_d Quat_d.setFromEuler_dAngles! ( in Float64 eulerX, in Float64 eulerY, in Float64 eulerZ )
Set this quat to a given angles vector (in radians) using the default XYZ rotation order
Quat_d Quat_d.setFromEuler_dAngles! ( in Float64 eulerX, in Float64 eulerY, in Float64 eulerZ, in RotationOrder ro )
Set this quat to a given angles vector (in radians) and a rotation order
Quat_d Quat_d.setFromEuler_dAngles! ( in Vec3_d angles )
Set this quat to a given angles vector (in radians) using the default XYZ rotation order
Quat_d Quat_d.setFromEuler_dAngles! ( in Vec3_d angles, in RotationOrder ro )
Set this quat to a given angles vector (in radians) and a rotation order
Quat_d Quat_d.setFromMat33_d! ( in Mat33_d mat )
Set this quat to the rotation described by a 3x3 rotation matrix
Quat_d.setIdentity! ()
Set this quat to the identity
Sets this quaternion to a unit quaternion and returns the previous length
Quat_d Quat_d.sphericalLinearInterpolate? ( in Quat_d q2, in Float64 t )
interpolates two quaternions spherically (slerp) given a scalar blend value (0.0 to 1.0).
注釈
this and q2 should be unit Quaternions
Quat_d Quat_d.subtract? ( in Quat_d other )
Overload method for the subtract operator
Euler_d Quat_d.toEuler_d? ( in RotationOrder rotationOrder )
Returns this quaternion as a Euler_d rotation giving a rotation order
Vec3_d Quat_d.toEuler_dAngles? ( in RotationOrder order )
Returns this quaternion as a Euler_d angles using the rotationorder XYZ
Vec3_d Quat_d.toEuler_dAngles? ()
Returns this quaternion as a Euler_d 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