Struct gdnative::core_types::Quat
source · [−]Expand description
Quaternion, used to represent 3D rotations.
Quaternions need to be normalized before all operations.
See also Quat in the Godot API doc.
Fields
x: f32
y: f32
z: f32
w: f32
Implementations
sourceimpl Quat
impl Quat
Helper methods for Quat
.
See the official Godot documentation
.
sourcepub const IDENTITY: Quat = Self::new(0.0, 0.0, 0.0, 1.0)
pub const IDENTITY: Quat = Self::new(0.0, 0.0, 0.0, 1.0)
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.
sourcepub const fn new(x: f32, y: f32, z: f32, w: f32) -> Quat
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Quat
Constructs a quaternion defined by the given values.
sourcepub fn from_basis(basis: &Basis) -> Quat
pub fn from_basis(basis: &Basis) -> Quat
Constructs a quaternion from the given Basis
sourcepub fn from_euler(euler: Vector3) -> Quat
pub fn from_euler(euler: Vector3) -> Quat
Constructs a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle).
sourcepub fn from_axis_angle(axis: Vector3, angle: f32) -> Quat
pub fn from_axis_angle(axis: Vector3, angle: f32) -> Quat
Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector.
sourcepub fn cubic_slerp(self, b: Quat, pre_a: Quat, post_b: Quat, t: f32) -> Quat
pub fn cubic_slerp(self, b: Quat, pre_a: Quat, post_b: Quat, t: f32) -> Quat
Performs a cubic spherical interpolation between quaternions pre_a
, this quaternion, b
,
and post_b
, by the given amount t
.
sourcepub fn to_euler(self) -> Vector3
pub fn to_euler(self) -> Vector3
Returns Euler angles (in the YXZ convention: when decomposing, 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).
sourcepub fn is_equal_approx(self, to: Quat) -> bool
pub fn is_equal_approx(self, to: Quat) -> bool
Returns true
if this quaternion and quat
are approximately equal, by running
is_equal_approx
on each component
sourcepub fn is_normalized(self) -> bool
pub fn is_normalized(self) -> bool
Returns whether the quaternion is normalized or not.
sourcepub fn length_squared(self) -> f32
pub fn length_squared(self) -> f32
Returns the length of the quaternion, squared.
sourcepub fn normalized(self) -> Quat
pub fn normalized(self) -> Quat
Returns a copy of the quaternion, normalized to unit length.
Normalization is necessary before transforming vectors through xform()
or *
.
sourcepub fn slerp(self, b: Quat, t: f32) -> Quat
pub fn slerp(self, b: Quat, t: f32) -> Quat
Returns the result of the spherical linear interpolation between this quaternion and to by amount weight.
Note: Both quaternions must be normalized.
Trait Implementations
sourceimpl CoerceFromVariant for Quat
impl CoerceFromVariant for Quat
fn coerce_from_variant(v: &Variant) -> Quat
sourceimpl<'de> Deserialize<'de> for Quat
impl<'de> Deserialize<'de> for Quat
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Quat, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Quat, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
sourceimpl Export for Quat
impl Export for Quat
sourcefn export_info(_hint: Option<<Quat as Export>::Hint>) -> ExportInfo
fn export_info(_hint: Option<<Quat as Export>::Hint>) -> ExportInfo
ExportInfo
given an optional typed hint.