unreal.Quat

class unreal.Quat(x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0)

Bases: StructBase

Quaternion. note: The full C++ class is located here: EngineSourceRuntimeCorePublicMathQuat.h

C++ Source:

  • Module: CoreUObject

  • File: NoExportTypes.h

Editor Properties: (see get_editor_property/set_editor_property)

  • w (double): [Read-Write]

  • x (double): [Read-Write]

  • y (double): [Read-Write] Alias for float/double depending on LWC status. Note: Will be refactored to double before UE5 ships.

  • z (double): [Read-Write]

IDENTITY: Quat

Identity quaternion constant

Type:

(Quat)

__add__(other: Quat) None

Overloads:

  • Quat Returns addition of Vector A and Vector B (A + B)

__eq__(other: object) bool

Overloads:

  • Quat Returns true if Quaternion A is equal to Quaternion B (A == B) within a specified error tolerance

__iadd__(other: Quat) None

Overloads:

  • Quat Returns addition of Vector A and Vector B (A + B)

__imul__(other: Quat) None

Overloads:

  • Quat Gets the result of multiplying two quaternions (A * B).

    Order matters when composing quaternions: C = A * B will yield a quaternion C that logically first applies B then A to any subsequent transformation (right first, then left).

    @param B The Quaternion to multiply by. @return The result of multiplication (A * B).

__isub__(other: Quat) None

Overloads:

  • Quat Returns subtraction of Vector B from Vector A (A - B)

__mul__(other: Quat) None

Overloads:

  • Quat Gets the result of multiplying two quaternions (A * B).

    Order matters when composing quaternions: C = A * B will yield a quaternion C that logically first applies B then A to any subsequent transformation (right first, then left).

    @param B The Quaternion to multiply by. @return The result of multiplication (A * B).

__ne__(other: object) bool

Overloads:

  • Quat Returns true if Quat A is not equal to Quat B (A != B) within a specified error tolerance

__sub__(other: Quat) None

Overloads:

  • Quat Returns subtraction of Vector B from Vector A (A - B)

add(b) Quat

Returns addition of Vector A and Vector B (A + B)

Parameters:

b (Quat) –

Return type:

Quat

angular_distance(b) float

Find the angular distance/difference between two rotation quaternions.

Parameters:

b (Quat) – Quaternion to find angle distance to

Returns:

angular distance in radians

Return type:

float

ensure_shortest_arc_to(b) None

Modify the quaternion to ensure that the delta between it and B represents the shortest possible rotation angle.

Parameters:

b (Quat) –

equals(b, tolerance=0.000100) bool

Returns true if Quaternion A is equal to Quaternion B (A == B) within a specified error tolerance

Parameters:
Return type:

bool

euler() Vector

Convert a Quaternion into floating-point Euler angles (in degrees).

Return type:

Vector

exp() Quat

Used in combination with Log(). Assumes a quaternion with W=0 and V=theta*v (where |v| = 1). Exp(q) = (sin(theta)*v, cos(theta))

Return type:

Quat

get_angle() float

Get the angle of this quaternion

Return type:

float

get_axis_x() Vector

Get the forward direction (X axis) after it has been rotated by this Quaternion.

Return type:

Vector

get_axis_y() Vector

Get the right direction (Y axis) after it has been rotated by this Quaternion.

Return type:

Vector

get_axis_z() Vector

Get the up direction (Z axis) after it has been rotated by this Quaternion.

Return type:

Vector

get_rotation_axis() Vector

Get the axis of rotation of the Quaternion. This is the axis around which rotation occurs to transform the canonical coordinate system to the target orientation. For the identity Quaternion which has no such rotation, FVector(1,0,0) is returned.

Return type:

Vector

interp_spring_to(target, spring_state, stiffness, critical_damping_factor, delta_time, mass=1.000000, target_velocity_amount=1.000000, initialize_from_target=False) -> (Quat, spring_state=QuaternionSpringState)

Uses a simple spring model to interpolate a quaternion from Current to Target.

Parameters:
  • target (Quat) – Target value

  • spring_state (QuaternionSpringState) – Data related to spring model (velocity, error, etc..) - Create a unique variable per spring

  • stiffness (float) – How stiff the spring model is (more stiffness means more oscillation around the target value)

  • critical_damping_factor (float) – How much damping to apply to the spring (0 means no damping, 1 means critically damped which means no oscillation)

  • delta_time (float) – Time difference since the last update

  • mass (float) – Multiplier that acts like mass on a spring

  • target_velocity_amount (float) – If 1 then the target velocity will be calculated and used, which results following the target more closely/without lag. Values down to zero (recommended when using this to smooth data) will progressively disable this effect.

  • initialize_from_target (bool) – If set then the current value will be set from the target on the first update

Returns:

spring_state (QuaternionSpringState): Data related to spring model (velocity, error, etc..) - Create a unique variable per spring

Return type:

QuaternionSpringState

inversed() Quat

Return an inversed copy of this quaternion.

Return type:

Quat

is_finite() bool

Determine if all the values are finite (not NaN nor Inf) in this Quat.

Return type:

bool

is_identity(tolerance=0.000100) bool

Checks whether this Quaternion is an Identity Quaternion. Assumes Quaternion tested is normalized.

Parameters:

tolerance (float) – Error tolerance for comparison with Identity Quaternion.

Returns:

true if Quaternion is a normalized Identity Quaternion.

Return type:

bool

is_non_finite() bool

Determine if there are any non-finite values (NaN or Inf) in this Quat.

Return type:

bool

is_normalized() bool

Return true if this quaternion is normalized

Return type:

bool

log() Quat

Quaternion with W=0 and V=theta*v. Used in combination with Exp().

Return type:

Quat

multiply(b) Quat

Gets the result of multiplying two quaternions (A * B).

Order matters when composing quaternions: C = A * B will yield a quaternion C that logically first applies B then A to any subsequent transformation (right first, then left).

Parameters:

b (Quat) – The Quaternion to multiply by.

Returns:

The result of multiplication (A * B).

Return type:

Quat

normalize(tolerance=0.000100) None

Normalize this quaternion if it is large enough as compared to the supplied tolerance. If it is too small then set it to the identity quaternion.

Parameters:

tolerance (float) – Minimum squared length of quaternion for normalization.

normalized(tolerance=0.000100) Quat

Get a normalized copy of this quaternion. If it is too small, returns an identity quaternion.

Parameters:

tolerance (float) – Minimum squared length of quaternion for normalization.

Return type:

Quat

not_equal(b, error_tolerance=0.000100) bool

Returns true if Quat A is not equal to Quat B (A != B) within a specified error tolerance

Parameters:
Return type:

bool

rotate_vector(v) Vector

Rotate a vector by this quaternion.

Parameters:

v (Vector) – the vector to be rotated

Returns:

vector after rotation

Return type:

Vector

rotator() Rotator

Converts to Rotator representation of this Quaternion.

Return type:

Rotator

set_components(x, y, z, w) None

Set X, Y, Z, W components of Quaternion.

Parameters:
set_from_euler(euler) None

Convert a vector of floating-point Euler angles (in degrees) into a Quaternion.

Parameters:

euler (Vector) – the Euler angles

size() float

Get the length of the quaternion.

Returns:

The length of the quaternion.

Return type:

float

size_squared() float

Get the squared length of the quaternion.

Returns:

The squared length of the quaternion.

Return type:

float

slerp_quat(b, alpha) Quat

Spherical interpolation between Quaternions. Result is normalized.

Parameters:
  • b (Quat) – The target quat we interp to

  • alpha (double) – The interpolation amount, usually 0 to 1.

Returns:

Quat after spherical interpolation

Return type:

Quat

subtract(b) Quat

Returns subtraction of Vector B from Vector A (A - B)

Parameters:

b (Quat) –

Return type:

Quat

unrotate_vector(v) Vector

Rotate a vector by the inverse of this quaternion.

Parameters:

v (Vector) – the vector to be rotated

Returns:

vector after rotation by the inverse of this quaternion.

Return type:

Vector

vector_forward() Vector

Get the forward direction (X axis) after it has been rotated by this Quaternion.

Return type:

Vector

vector_right() Vector

Get the right direction (Y axis) after it has been rotated by this Quaternion.

Return type:

Vector

vector_up() Vector

Get the up direction (Z axis) after it has been rotated by this Quaternion.

Return type:

Vector

property w: float

[Read-Write]

Type:

(double)

property x: float

[Read-Write]

Type:

(double)

property y: float

Will be refactored to double before UE5 ships.

Type:

(double)

Type:

[Read-Write] Alias for float/double depending on LWC status. Note

property z: float

[Read-Write]

Type:

(double)