Class Quat
Quat metatype, wrapper for godot_quat
.
Constructed using the idiom Quat(...)
, which calls __new.
The X, Y, Z and W components may be accessed through elements
or individually
with x/y/z/w
. Vector2 with two adjacent components may be get/set with the
pairs xy/yz/zw
. Vector3 with three adjacent components may be get/set with
the triplets xyz/yzw
:
typedef union godot_quat {
float elements[4];
struct { float x, y, z, w; };
struct { Vector2 xy; Vector2 zw; };
struct { float _; Vector2 yz; float _; };
struct { Vector3 xyz; float _; };
struct { float _; Vector3 yzw; };
} godot_quat;
Methods
Quat:cubic_slerp (b, preA, postB, t) | Performs a cubic spherical interpolation between quaternions preA , this vector, b , and postB , by the given amount t . |
Quat:dot (b) | Returns the dot product of two quaternions. |
Quat:inverse () | Returns the inverse of the quaternion. |
Quat:is_normalized () | Returns whether the quaternion is normalized or not. |
Quat:length () | Returns the length of the quaternion. |
Quat:length_squared () | Returns the length of the quaternion, squared. |
Quat:normalized () | Returns a copy of the quaternion, normalized to unit length. |
Quat:slerp (to, weight) | Returns the result of the spherical linear interpolation between this quaternion and to by amount weight . |
Quat:slerpni (to, weight) | Returns the result of the spherical linear interpolation between this quaternion and to by amount weight , but without checking if the rotation path is not bigger than 90 degrees. |
Quat:unpack () | Returns all elements. |
Quat:xform (v) | Returns a vector transformed (multiplied) by this quaternion. |
Metamethods
Quat:__add (a, b) | Addition operation |
Quat:__concat (a, b) | Concatenates values. |
Quat:__div (a, s) | Division operation |
Quat:__eq (a, b) | Equality operation
If either a or b are not of type Quat, always return false . |
Quat:__mul (a, b) | Multiplication operation |
Quat:__new (...) | Quat constructor, called by the idiom Quat(...) . |
Quat:__sub (a, b) | Subtraction operation |
Quat:__tostring () | Returns a Lua string representation of this quaternion. |
Quat:__unm () | Unary minus operation |
Constants
Quat.IDENTITY | The identity quaternion, representing no rotation. |
Methods
- Quat:cubic_slerp (b, preA, postB, t)
-
Performs a cubic spherical interpolation between quaternions
preA
, this vector,b
, andpostB
, by the given amountt
.Parameters:
Returns:
- Quat:dot (b)
-
Returns the dot product of two quaternions.
Parameters:
- b Quat
Returns:
-
number
- Quat:inverse ()
-
Returns the inverse of the quaternion.
Returns:
- Quat:is_normalized ()
-
Returns whether the quaternion is normalized or not.
Returns:
-
bool
- Quat:length ()
-
Returns the length of the quaternion.
Returns:
-
number
- Quat:length_squared ()
-
Returns the length of the quaternion, squared.
Returns:
-
number
- Quat:normalized ()
-
Returns a copy of the quaternion, normalized to unit length.
Returns:
- Quat:slerp (to, weight)
-
Returns the result of the spherical linear interpolation between this quaternion and
to
by amountweight
. Note: Both quaternions must be normalized.Parameters:
- to Quat
- weight number
Returns:
See also:
- Quat:slerpni (to, weight)
-
Returns the result of the spherical linear interpolation between this quaternion and
to
by amountweight
, but without checking if the rotation path is not bigger than 90 degrees. Note: Both quaternions must be normalized.Parameters:
- to Quat
- weight number
Returns:
See also:
- Quat:unpack ()
-
Returns all elements.
Returns:
- number X
- number Y
- number Z
- number W
- Quat:xform (v)
-
Returns a vector transformed (multiplied) by this quaternion.
Parameters:
- v Vector3
Returns:
Metamethods
- Quat:__add (a, b)
-
Addition operation
Parameters:
Returns:
- Quat:__concat (a, b)
-
Concatenates values.
Parameters:
Returns:
- Quat:__div (a, s)
-
Division operation
Parameters:
- a Quat
- s number
Returns:
- Quat:__eq (a, b)
-
Equality operation
If either
a
orb
are not of type Quat, always returnfalse
.Parameters:
Returns:
-
bool
- Quat:__mul (a, b)
-
Multiplication operation
Parameters:
- a Quat
- b
Vector3 or number
If a Vector3 is passed, calls xform.
Otherwise, returns a Quat with each component multiplied by
b
.
Returns:
- Quat:__new (...)
-
Quat constructor, called by the idiom
Quat(...)
.Quat()
: IDENTITY quaternion (Quat() == Quat(0, 0, 0, 1)
)Quat(number x[, number y = 0[, number z = 0[, number w = 1]]])
: set XYZWQuat(Basis basis)
: construct from basisQuat(Vector3 euler)
: rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last)Quat(Vector3 axis, number angle)
: rotates around the given axis by the specified angle. The axis must be a normalized vector.Quat(Quat other)
: copy values fromother
Parameters:
- ...
Returns:
- Quat:__sub (a, b)
-
Subtraction operation
Parameters:
Returns:
- Quat:__tostring ()
-
Returns a Lua string representation of this quaternion.
Returns:
- Quat:__unm ()
-
Unary minus operation
Returns:
Constants
- Quat.IDENTITY
-
The identity quaternion, representing no rotation.
Equivalent to an identity Basis matrix. If a vector is transformed by an identity quaternion, it will not change.
- IDENTITY Quat(0, 0, 0, 1)