Quat

Quaternion.

Description

A unit quaternion used for representing 3D rotations.

It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. But due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.

Quaternions need to be (re)normalized.

Properties

floatw1.0
floatx0.0
floaty0.0
floatz0.0

Constants

  • IDENTITY = Quat( 0, 0, 0, 1 ) — The identity rotation. Equivalent to an identity matrix. If a vector is transformed by an identity quaternion, it will not change.

Property Descriptions

Default1.0

W component of the quaternion.


Default0.0

X component of the quaternion.


Default0.0

Y component of the quaternion.


Default0.0

Z component of the quaternion.

Method Descriptions

Returns the rotation matrix corresponding to the given quaternion.


Returns a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).


Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.


Returns a quaternion defined by these values.


Performs a cubic spherical-linear interpolation with another quaternion.


Returns the dot product of two quaternions.


Returns Euler angles (in the YXZ convention: first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).


Returns the inverse of the quaternion.


Returns true if this quaterion and quat are approximately equal, by running @GDScript.is_equal_approx on each component.


  • bool is_normalized ( )

Returns whether the quaternion is normalized or not.


Returns the length of the quaternion.


Returns the length of the quaternion, squared.


Returns a copy of the quaternion, normalized to unit length.


Sets the quaternion to a rotation which rotates around axis by the specified angle, in radians. The axis must be a normalized vector.


Sets the quaternion to a rotation specified by Euler angles (in the YXZ convention: first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).


Performs a spherical-linear interpolation with another quaternion.


Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°.


Transforms the vector v by this quaternion.

Doc ID missing

Disclaimer: This page has been automaticaly and directly extracted from the official Godot Docs website, the 1970-01-01 at 00:00:00. It’s the English Stable version because it’s what most Godot users should use. The Copyright owners are Juan Linietsky, Ariel Manzur and the Godot community. CC-BY 3.0. Thanks for your patience and generosity.