Quaternion

Struct Quaternion 

Source
#[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§

Source§

impl Quaternion

Source

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.

Source

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

Source

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.

Source

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_fromarc_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)

Source

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

Source

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

Source

pub fn exp(self) -> Quaternion

Source

pub fn from_euler(euler: Vector3) -> Quaternion

Source

pub fn get_angle(self) -> f32

Source

pub fn get_axis(self) -> Vector3

Source

pub fn get_euler(self) -> Vector3

Returns the rotation of the matrix in euler angles, with the order YXZ.

See get_euler_with() for custom angle orders.

Source

pub fn get_euler_with(self, order: EulerOrder) -> Vector3

Returns the rotation of the matrix in euler angles.

The order of the angles are given by order. To use the default order YXZ, see get_euler().

Godot equivalent: Quaternion.get_euler()

Source

pub fn inverse(self) -> Quaternion

Source

pub fn is_finite(self) -> bool

Source

pub fn is_normalized(self) -> bool

Source

pub fn length(self) -> f32

Source

pub fn length_squared(self) -> f32

Source

pub fn log(self) -> Quaternion

Source

pub fn normalized(self) -> Quaternion

§Panics

If the quaternion has length of 0.

Source

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

§Panics

If either quaternion is not normalized.

Source

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

§Panics

If either quaternion is not normalized.

Source

pub fn spherical_cubic_interpolate( self, b: Quaternion, pre_a: Quaternion, post_b: Quaternion, weight: f32, ) -> Quaternion

§Panics

If any quaternions are not normalized.

Source

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§

Source§

impl Add for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Quaternion

Source§

fn add_assign(&mut self, other: Quaternion)

Performs the += operation. Read more
Source§

impl ApproxEq for Quaternion

Source§

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

Source§

impl Clone for Quaternion

Source§

fn clone(&self) -> Quaternion

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Quaternion

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Quaternion

Source§

fn default() -> Quaternion

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

impl Display for Quaternion

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Div<f32> for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Quaternion

Source§

fn div_assign(&mut self, other: f32)

Performs the /= operation. Read more
Source§

impl DynamicSend for Quaternion

Source§

impl Export for Quaternion

Source§

fn export_hint() -> PropertyHintInfo

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

impl FromGodot for Quaternion

Source§

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

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

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

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

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

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

fn from_variant(variant: &Variant) -> Self

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

impl GodotConvert for Quaternion

Source§

type Via = Quaternion

The type through which Self is represented in Godot.
Source§

impl IntoDynamicSend for Quaternion

Source§

impl Mul<Vector3> for Quaternion

Source§

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.

Source§

type Output = Vector3

The resulting type after applying the * operator.
Source§

impl Mul<f32> for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Quaternion

Source§

fn mul_assign(&mut self, other: f32)

Performs the *= operation. Read more
Source§

impl MulAssign for Quaternion

Source§

fn mul_assign(&mut self, other: Quaternion)

Performs the *= operation. Read more
Source§

impl Neg for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the - operator.
Source§

fn neg(self) -> Quaternion

Performs the unary - operation. Read more
Source§

impl PartialEq for Quaternion

Source§

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.
Source§

impl Sub for Quaternion

Source§

type Output = Quaternion

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Quaternion

Source§

fn sub_assign(&mut self, other: Quaternion)

Performs the -= operation. Read more
Source§

impl ToGodot for Quaternion

Source§

type Pass = ByValue

Whether arguments of this type are passed by value or by reference. Read more
Source§

fn to_godot(&self) -> <Quaternion as GodotConvert>::Via

Converts this type to Godot representation, optimizing for zero-copy when possible. Read more
Source§

fn to_godot_owned(&self) -> Self::Via
where Self::Via: Clone,

Converts this type to owned Godot representation. Read more
Source§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
Source§

impl Var for Quaternion

Source§

fn get_property(&self) -> <Quaternion as GodotConvert>::Via

Source§

fn set_property(&mut self, value: <Quaternion as GodotConvert>::Via)

Source§

fn var_hint() -> PropertyHintInfo

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

impl ArrayElement for Quaternion

Source§

impl BuiltinExport for Quaternion

Source§

impl Copy for Quaternion

Source§

impl GodotType for Quaternion

Source§

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> AsArg<T> for T
where T: ToGodot<Pass = ByValue>,

Source§

fn into_arg<'arg>(self) -> CowArg<'arg, T>
where T: 'arg,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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§

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.