Skip to content

Quaternion

The Quaternion class is used to represent rotations. It describes a rotational transformation in a three-dimensional space.

构造方法

Quaternion.new ( x : number? , y : number? , z : number? , w : number? )
Create a new quaternion.

成员变量

Quaternion.x : number
The X component of the quaternion.
Quaternion.y : number
The y component of the quaternion.
Quaternion.z : number
The z component of the quaternion.
Quaternion.w : number
The w component of the quaternion.
Quaternion.eulerAngles : Vector3
(Read Only) The rotation Euler angles represented by the quaternion.
Quaternion.normalized : Quaternion
(Read Only) Normalizes the quaternion to a unit quaternion with a length of 1, preserving the original rotation direction and angle of the quaternion. Returns a new normalized quaternion.
Quaternion.zAxis : Vector3
(Read Only) The rotation axis vector in the z-axis direction of the quaternion.
Quaternion.inverse : Quaternion
(Read Only) The inverse quaternion of the current quaternion.
Quaternion.negative : Quaternion
(Read Only) Negates the current quaternion and returns a new quaternion object.
Quaternion.xAxis : Vector3
(Read Only) The rotation axis vector in the x-axis direction of the quaternion.
Quaternion.yAxis : Vector3
(Read Only) The rotation axis vector in the y-axis direction of the quaternion.
Quaternion.almostZero : boolean
(Read Only) Determines if the quaternion is close to zero.

静态变量

Quaternion.zero : Quaternion
A quaternion value with x, y, z, and w components all set to 0. It has no practical meaning.
Quaternion.identity : Quaternion
(Read Only) The quaternion of the unit.

成员方法

Quaternion.SetValues ( x : number , y : number , z : number , w : number ) : void
Set the individual components of a quaternion.
Quaternion.ToAxis ( ref_xaxis : Vector3 , ref_yaxis : Vector3 , ref_zaxis : Vector3 ) : void
Returns three axis vectors transformed by a quaternion.
Quaternion.ToAxisAngle ( ref_axis : Vector3 ) : number
Returns the axis vector and rotation angle of a quaternion conversion through parameters and return values.
Quaternion.Inverse ( ) : void
Modifies the current quaternion object to its inverse quaternion.
Quaternion.Negative ( ) : void
Inverts the current quaternion.
Quaternion.Normalize ( ) : void
Normalize the quaternion to a unit quaternion with a length of 1, while preserving the original quaternion's rotation direction and angle.
Quaternion.RotateVector ( src : Vector3 ) : Vector3
Calculates the vector after rotating the target vector by the current quaternion.
Quaternion.InvertRotateVector ( src : Vector3 ) : Vector3
Calculate the vector after inverse rotation around the current quaternion.
Quaternion.Mul ( rhs : Quaternion ) : Quaternion
Multiplies the current quaternion with the specified quaternion and returns a new quaternion object.
Quaternion.toString ( ) : string
Converts a quaternion to a string representation.
Quaternion.CopyFrom ( from : Quaternion ) : void
Copies the values from the specified quaternion to the current quaternion.
Quaternion.Get ( index : number ) : number
Get the component of the quaternion by index.
Quaternion.Set ( index : number , value : number ) : void
Set the component of the quaternion based on the index.
Quaternion.Add ( rhs : Quaternion ) : Quaternion
Adds the current quaternion with the specified quaternion and returns a new quaternion object.
Quaternion.Sub ( rhs : Quaternion ) : Quaternion
Subtracts the specified quaternion from the current quaternion and returns a new quaternion object.
Quaternion.AddAssign ( rhs : Quaternion ) : void
Adds the specified quaternion to the current quaternion.
Quaternion.SubAssign ( rhs : Quaternion ) : void
Subtracts the specified quaternion from the current quaternion.
Quaternion.MulAssign ( rhs : Quaternion ) : void
Multiplies the current quaternion by the specified quaternion.
Quaternion.EqualsTo ( other : Quaternion ) : boolean
Determines whether the quaternion is approximately equal to the target quaternion.

静态方法

Quaternion.Clone ( val : Quaternion ) : Quaternion
Get a clone of the specified quaternion and return a new quaternion.
Quaternion.Dot ( lhs : Quaternion , rhs : Quaternion ) : number
Performs a dot product operation on the quaternions lhs and rhs.
Quaternion.LookRotation ( forward : Vector3 , up : Vector3? ) : Quaternion
Create a quaternion with the specified forward and up directions.
Quaternion.Angle ( lhs : Quaternion , rhs : Quaternion ) : number
Returns the angle between two rotations, lhs and rhs.
Quaternion.FromEuler ( euler : Vector3 ) : Quaternion
Converts Euler angles to a quaternion and returns it.
Quaternion.FromEulerXYZ ( x : number , y : number , z : number ) : Quaternion
Converts a set of Euler angles to a quaternion and returns it.
Quaternion.AxisToQuaternion ( x : Vector3 , y : Vector3 , z : Vector3 ) : Quaternion
Calculate the quaternion rotation based on three normal vectors.
Quaternion.AngleAxis ( angle : number , axis : Vector3 ) : Quaternion
Create a rotation that rotates around an axis by a specified angle.
Quaternion.Lerp ( q1 : Quaternion , q2 : Quaternion , t : number ) : Quaternion
Interpolates between q1 and q2 by t and then normalizes the result.
Quaternion.Slerp ( q1 : Quaternion , q2 : Quaternion , t : number ) : Quaternion
Performs spherical interpolation between two quaternions.
Quaternion.RotateTowards ( from : Quaternion , to : Quaternion , max_delta_degrees : number ) : Quaternion
Rotates a quaternion from the current direction to the target direction.
Quaternion.FromToRotation ( from_dir : Quaternion , to_dir : Quaternion ) : Quaternion
Creates a quaternion that rotates from the direction specified by from_dir to the direction specified by to_dir.
Quaternion.EqualsTo ( lhs : Quaternion , rhs : Quaternion ) : boolean
Determines if the quaternion is approximately equal to the target quaternion.