Struct Quaternion
#[repr(C)]pub struct Quaternion {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
Expand description
Unit quaternion to represent 3D rotations.
See also Quaternion
in the Godot documentation.
§Godot docs
Fields§
§x: f32
§y: f32
§z: f32
§w: f32
Implementations§
§impl Quaternion
impl Quaternion
pub const IDENTITY: Quaternion
pub const IDENTITY: Quaternion
The identity quaternion, representing no rotation. This has the same rotation as Basis::IDENTITY
.
If a Vector3
is rotated (multiplied) by this quaternion, it does not change.
pub fn new(x: f32, y: f32, z: f32, w: f32) -> Quaternion
pub fn from_axis_angle(axis: Vector3, angle: f32) -> Quaternion
pub fn from_axis_angle(axis: Vector3, angle: f32) -> Quaternion
pub fn from_rotation_arc(arc_from: Vector3, arc_to: Vector3) -> Quaternion
pub fn from_rotation_arc(arc_from: Vector3, arc_to: Vector3) -> Quaternion
Constructs a Quaternion representing the shortest arc between arc_from
and arc_to
.
These can be imagined as two points intersecting a unit sphere’s surface, with a radius of 1.0.
The inputs must be unit vectors.
For near-singular cases (arc_from
≈arc_to
or arc_from
≈-arc_to
) the current implementation is only accurate to about
0.001, or better if double-precision
is enabled.
Godot equivalent: Quaternion(arc_from: Vector3, arc_to: Vector3)
pub fn angle_to(self, to: Quaternion) -> f32
pub fn dot(self, with: Quaternion) -> f32
pub fn exp(self) -> Quaternion
pub fn to_exp(self) -> Quaternion
Quaternion::exp()
pub fn from_euler(euler: Vector3) -> Quaternion
pub fn get_angle(self) -> f32
pub fn get_axis(self) -> Vector3
pub fn to_euler(self, order: EulerOrder) -> Vector3
pub fn inverse(self) -> Quaternion
pub fn is_finite(self) -> bool
pub fn is_normalized(self) -> bool
pub fn length(self) -> f32
pub fn length_squared(self) -> f32
pub fn log(self) -> Quaternion
pub fn normalized(self) -> Quaternion
pub fn normalized(self) -> Quaternion
§Panics
If the quaternion has length of 0.
pub fn slerp(self, to: Quaternion, weight: f32) -> Quaternion
pub fn slerp(self, to: Quaternion, weight: f32) -> Quaternion
§Panics
If either quaternion is not normalized.
pub fn slerpni(self, to: Quaternion, weight: f32) -> Quaternion
pub fn slerpni(self, to: Quaternion, weight: f32) -> Quaternion
§Panics
If either quaternion is not normalized.
pub fn spherical_cubic_interpolate(
self,
b: Quaternion,
pre_a: Quaternion,
post_b: Quaternion,
weight: f32,
) -> Quaternion
pub fn spherical_cubic_interpolate( self, b: Quaternion, pre_a: Quaternion, post_b: Quaternion, weight: f32, ) -> Quaternion
§Panics
If any quaternions are not normalized.
pub fn spherical_cubic_interpolate_in_time(
self,
b: Quaternion,
pre_a: Quaternion,
post_b: Quaternion,
weight: f32,
b_t: f32,
pre_a_t: f32,
post_b_t: f32,
) -> Quaternion
pub fn spherical_cubic_interpolate_in_time( self, b: Quaternion, pre_a: Quaternion, post_b: Quaternion, weight: f32, b_t: f32, pre_a_t: f32, post_b_t: f32, ) -> Quaternion
§Panics
If any quaternions are not normalized.
Trait Implementations§
§impl Add for Quaternion
impl Add for Quaternion
§type Output = Quaternion
type Output = Quaternion
+
operator.§fn add(self, other: Quaternion) -> Quaternion
fn add(self, other: Quaternion) -> Quaternion
+
operation. Read more§impl AddAssign for Quaternion
impl AddAssign for Quaternion
§fn add_assign(&mut self, other: Quaternion)
fn add_assign(&mut self, other: Quaternion)
+=
operation. Read more§impl ApproxEq for Quaternion
impl ApproxEq for Quaternion
fn approx_eq(&self, other: &Quaternion) -> bool
§impl Clone for Quaternion
impl Clone for Quaternion
§fn clone(&self) -> Quaternion
fn clone(&self) -> Quaternion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for Quaternion
impl Debug for Quaternion
§impl Default for Quaternion
impl Default for Quaternion
§fn default() -> Quaternion
fn default() -> Quaternion
§impl Display for Quaternion
impl Display for Quaternion
§impl Div<f32> for Quaternion
impl Div<f32> for Quaternion
§type Output = Quaternion
type Output = Quaternion
/
operator.§fn div(self, other: f32) -> Quaternion
fn div(self, other: f32) -> Quaternion
/
operation. Read more§impl DivAssign<f32> for Quaternion
impl DivAssign<f32> for Quaternion
§fn div_assign(&mut self, other: f32)
fn div_assign(&mut self, other: f32)
/=
operation. Read more§impl Export for Quaternion
impl Export for Quaternion
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§impl FromGodot for Quaternion
impl FromGodot for Quaternion
§fn try_from_godot(
via: <Quaternion as GodotConvert>::Via,
) -> Result<Quaternion, ConvertError>
fn try_from_godot( via: <Quaternion as GodotConvert>::Via, ) -> Result<Quaternion, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl GodotConvert for Quaternion
impl GodotConvert for Quaternion
§type Via = Quaternion
type Via = Quaternion
Self
is represented in Godot.§impl Mul<Vector3> for Quaternion
impl Mul<Vector3> for Quaternion
§impl Mul<f32> for Quaternion
impl Mul<f32> for Quaternion
§type Output = Quaternion
type Output = Quaternion
*
operator.§fn mul(self, other: f32) -> Quaternion
fn mul(self, other: f32) -> Quaternion
*
operation. Read more§impl Mul for Quaternion
impl Mul for Quaternion
§type Output = Quaternion
type Output = Quaternion
*
operator.§fn mul(self, other: Quaternion) -> Quaternion
fn mul(self, other: Quaternion) -> Quaternion
*
operation. Read more§impl MulAssign<f32> for Quaternion
impl MulAssign<f32> for Quaternion
§fn mul_assign(&mut self, other: f32)
fn mul_assign(&mut self, other: f32)
*=
operation. Read more§impl MulAssign for Quaternion
impl MulAssign for Quaternion
§fn mul_assign(&mut self, other: Quaternion)
fn mul_assign(&mut self, other: Quaternion)
*=
operation. Read more§impl Neg for Quaternion
impl Neg for Quaternion
§type Output = Quaternion
type Output = Quaternion
-
operator.§fn neg(self) -> Quaternion
fn neg(self) -> Quaternion
-
operation. Read more§impl ParamType for Quaternion
impl ParamType for Quaternion
§fn owned_to_arg<'v>(self) -> <Quaternion as ParamType>::Arg<'v>
fn owned_to_arg<'v>(self) -> <Quaternion as ParamType>::Arg<'v>
impl AsArg<T>
. Read more§impl PartialEq for Quaternion
impl PartialEq for Quaternion
§impl Sub for Quaternion
impl Sub for Quaternion
§type Output = Quaternion
type Output = Quaternion
-
operator.§fn sub(self, other: Quaternion) -> Quaternion
fn sub(self, other: Quaternion) -> Quaternion
-
operation. Read more§impl SubAssign for Quaternion
impl SubAssign for Quaternion
§fn sub_assign(&mut self, other: Quaternion)
fn sub_assign(&mut self, other: Quaternion)
-=
operation. Read more§impl ToGodot for Quaternion
impl ToGodot for Quaternion
§type ToVia<'v> = <Quaternion as GodotConvert>::Via
type ToVia<'v> = <Quaternion as GodotConvert>::Via
§fn to_godot(&self) -> <Quaternion as ToGodot>::ToVia<'_>
fn to_godot(&self) -> <Quaternion as ToGodot>::ToVia<'_>
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl Var for Quaternion
impl Var for Quaternion
fn get_property(&self) -> <Quaternion as GodotConvert>::Via
fn set_property(&mut self, value: <Quaternion as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.