godot::builtin

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

Quaternion (stable)

Fields§

§x: f32§y: f32§z: f32§w: f32

Implementations§

§

impl Quaternion

pub fn new(x: f32, y: f32, z: f32, w: f32) -> Quaternion

pub fn from_axis_angle(axis: Vector3, angle: f32) -> Quaternion

Creates a quaternion from a Vector3 and an angle.

§Panics

If the vector3 is not normalized.

pub fn angle_to(self, to: Quaternion) -> f32

pub fn dot(self, with: Quaternion) -> f32

pub fn to_exp(self) -> Quaternion

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

§Panics

If the quaternion has length of 0.

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

§Panics

If either quaternion is not normalized.

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

§Panics

If any quaternions are not normalized.

Trait Implementations§

§

impl Add for Quaternion

§

type Output = Quaternion

The resulting type after applying the + operator.
§

fn add(self, other: Quaternion) -> Quaternion

Performs the + operation. Read more
§

impl AddAssign for Quaternion

§

fn add_assign(&mut self, other: Quaternion)

Performs the += operation. Read more
§

impl ApproxEq for Quaternion

§

fn approx_eq(&self, other: &Quaternion) -> bool

§

impl Clone for Quaternion

§

fn clone(&self) -> Quaternion

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Quaternion

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Quaternion

§

fn default() -> Quaternion

Returns the “default value” for a type. Read more
§

impl Display for Quaternion

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Div<f32> for Quaternion

§

type Output = Quaternion

The resulting type after applying the / operator.
§

fn div(self, other: f32) -> Quaternion

Performs the / operation. Read more
§

impl DivAssign<f32> for Quaternion

§

fn div_assign(&mut self, other: f32)

Performs the /= operation. Read more
§

impl Export for Quaternion

§

fn export_hint() -> PropertyHintInfo

The export info to use for an exported field of this type, if no other export info is specified.
§

impl FromGodot for Quaternion

§

fn try_from_godot( via: <Quaternion as GodotConvert>::Via, ) -> Result<Quaternion, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
§

fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

Performs the conversion from a Variant, returning Err on failure.
§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a Variant. Read more
§

impl GodotConvert for Quaternion

§

type Via = Quaternion

The type through which Self is represented in Godot.
§

impl Mul<Vector3> for Quaternion

§

fn mul(self, rhs: Vector3) -> <Quaternion as Mul<Vector3>>::Output

Applies the quaternion’s rotation to the 3D point represented by the vector.

§Panics

If the quaternion is not normalized.

§

type Output = Vector3

The resulting type after applying the * operator.
§

impl Mul<f32> for Quaternion

§

type Output = Quaternion

The resulting type after applying the * operator.
§

fn mul(self, other: f32) -> Quaternion

Performs the * operation. Read more
§

impl Mul for Quaternion

§

type Output = Quaternion

The resulting type after applying the * operator.
§

fn mul(self, other: Quaternion) -> Quaternion

Performs the * operation. Read more
§

impl MulAssign<f32> for Quaternion

§

fn mul_assign(&mut self, other: f32)

Performs the *= operation. Read more
§

impl MulAssign for Quaternion

§

fn mul_assign(&mut self, other: Quaternion)

Performs the *= operation. Read more
§

impl Neg for Quaternion

§

type Output = Quaternion

The resulting type after applying the - operator.
§

fn neg(self) -> Quaternion

Performs the unary - operation. Read more
§

impl ParamType for Quaternion

§

fn owned_to_arg<'v>(self) -> <Quaternion as ParamType>::Arg<'v>

Converts an owned value to the canonical argument type, which can be passed to impl AsArg<T>. Read more
§

impl PartialEq for Quaternion

§

fn eq(&self, other: &Quaternion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Sub for Quaternion

§

type Output = Quaternion

The resulting type after applying the - operator.
§

fn sub(self, other: Quaternion) -> Quaternion

Performs the - operation. Read more
§

impl SubAssign for Quaternion

§

fn sub_assign(&mut self, other: Quaternion)

Performs the -= operation. Read more
§

impl ToGodot for Quaternion

§

type ToVia<'v> = <Quaternion as GodotConvert>::Via

Target type of to_godot(), which can differ from Via for pass-by-reference types. Read more
§

fn to_godot(&self) -> <Quaternion as ToGodot>::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
§

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

Specific property hints, only override if they deviate from GodotType::property_info, e.g. for enums/newtypes.
§

impl ArrayElement for Quaternion

§

impl AsArg<Quaternion> for Quaternion

§

impl Copy for Quaternion

§

impl GodotType for Quaternion

§

impl StructuralPartialEq for Quaternion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.