# Quat¶

Category: Built-In Types

Quaternion.

## Properties¶

 float w float x float y float z

## Methods¶

 Quat Quat ( Basis from ) Quat Quat ( Vector3 euler ) Quat Quat ( Vector3 axis, float angle ) Quat Quat ( float x, float y, float z, float w ) Quat cubic_slerp ( Quat b, Quat pre_a, Quat post_b, float t ) float dot ( Quat b ) Vector3 get_euler ( ) Quat inverse ( ) bool is_normalized ( ) float length ( ) float length_squared ( ) Quat normalized ( ) void set_axis_angle ( Vector3 axis, float angle ) void set_euler ( Vector3 euler ) Quat slerp ( Quat b, float t ) Quat slerpni ( Quat b, float t ) Vector3 xform ( Vector3 v )

## Constants¶

• IDENTITY = Quat( 0, 0, 0, 1 )

## 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.

## Property Descriptions¶

W component of the quaternion. Default value: `1`

X component of the quaternion. Default value: `0`

Y component of the quaternion. Default value: `0`

Z component of the quaternion. Default value: `0`

## 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.

Return 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.

• bool is_normalized ( )

Returns whether the quaternion is normalized or not.

Returns the length of the quaternion.

• float length_squared ( )

Returns the length of the quaternion, squared.

• Quat normalized ( )

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

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

Set 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.