Struct Quaternion

Source
pub struct Quaternion<T> {
    pub s: T,
    pub v: Vector3<T>,
}
Expand description

A quaternion, composed of a scalar and a Vector3.

Fields§

§s: T§v: Vector3<T>

Implementations§

Source§

impl<T> Quaternion<T>

Source

pub const fn new(w: T, xi: T, yj: T, zk: T) -> Quaternion<T>

Constructs a Quaternion from one scalar and three imaginary components.

Source

pub fn from_sv(s: T, v: Vector3<T>) -> Quaternion<T>

Constructs a Quaternion from a scalar and a vector.

Source§

impl<T> Quaternion<T>
where T: Real + Clone + Debug,

Source

pub fn from_axis_angle(axis: Vector3<T>, angle: T) -> Self

Constructs the rotation as a rotation along an axis.

Source§

impl<T> Quaternion<T>
where T: Zero + One,

Source

pub fn identity() -> Self

Return the identity quaternion.

Source§

impl<T> Quaternion<T>
where T: Clone,

Source

pub fn s(&self) -> &T

Source

pub fn s_mut(&mut self) -> &mut T

Source§

impl<T> Quaternion<T>
where T: Neg<Output = T>,

Source

pub fn conjugate(self) -> Self

Returns the conjugate of the quaternion.

Trait Implementations§

Source§

impl<T> Add for Quaternion<T>
where T: Add<T, Output = T>,

Source§

type Output = Quaternion<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quaternion<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Quaternion<T>

Source§

fn clone(&self) -> Quaternion<T>

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

impl<T> Debug for Quaternion<T>
where T: Debug,

Source§

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

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

impl<'de, T> Deserialize<'de> for Quaternion<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Div<T> for Quaternion<T>
where T: Real + Clone,

Source§

type Output = Quaternion<T>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> Self

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Quaternion<T>
where T: Real + Clone,

Source§

fn div_assign(&mut self, scalar: T)

Performs the /= operation. Read more
Source§

impl<T> From<Euler<T>> for Quaternion<T>
where T: Real + Clone,

Source§

fn from(euler: Euler<T>) -> Quaternion<T>

Converts to this type from the input type.
Source§

impl<T> From<Orthonormal<T, 3>> for Quaternion<T>
where T: Copy + Clone + PartialOrd + Product + Real + One + Zero + Neg<Output = T> + Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + Div<T, Output = T>,

Source§

fn from(orthonormal: Orthonormal<T, 3>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Quaternion<T>> for Matrix3<T>
where T: Real + One + Copy + Clone,

Source§

fn from(quat: Quaternion<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Quaternion<T>> for Matrix4<T>
where T: Add + Mul + Sub + Real + Zero + One + Copy + Clone,

Source§

fn from(quat: Quaternion<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Quaternion<f32>> for Euler<f32>

Source§

fn from(q: Quaternion<f32>) -> Euler<f32>

Converts to this type from the input type.
Source§

impl From<Quaternion<f64>> for Euler<f64>

Source§

fn from(q: Quaternion<f64>) -> Euler<f64>

Converts to this type from the input type.
Source§

impl<T> InnerSpace for Quaternion<T>
where T: Real + Zero + Clone,

Source§

fn dot(self, other: Self) -> Self::Scalar

Return the inner (also known as “dot”) product.
Source§

fn magnitude2(self) -> Self::Scalar

Returns the squared length of the value.
Source§

fn reflect(self, surface_normal: Unit<Self>) -> Self

Returns the reflection of the current vector with respect to the given surface normal. The surface normal must be of length 1 for the return value to be correct. The current vector is interpreted as pointing toward the surface, and does not need to be normalized.
Source§

impl<T> MetricSpace for Quaternion<T>
where T: Real + Zero + Clone,

Source§

type Metric = T

Source§

fn distance2(self, other: Self) -> T

Returns the distance squared between the two values.
Source§

impl Mul<Quaternion<f32>> for f32

Source§

type Output = Quaternion<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, quat: Quaternion<f32>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Quaternion<f64>> for f64

Source§

type Output = Quaternion<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, quat: Quaternion<f64>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for Quaternion<T>
where T: Real + Clone,

Source§

type Output = Quaternion<T>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: T) -> Self

Performs the * operation. Read more
Source§

impl<T> Mul<Vector3<T>> for Quaternion<T>
where T: Real + Clone,

Source§

type Output = Vector3<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector3<T>) -> Vector3<T>

Performs the * operation. Read more
Source§

impl<T> Mul for Quaternion<T>
where T: Real + Clone,

Source§

type Output = Quaternion<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Quaternion<T>) -> Self

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Quaternion<T>
where T: Real + Clone,

Source§

fn mul_assign(&mut self, scalar: T)

Performs the *= operation. Read more
Source§

impl<T> Neg for Quaternion<T>
where T: Neg<Output = T>,

Source§

type Output = Quaternion<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T> One for Quaternion<T>
where T: One,

Source§

fn one() -> Self

Returns the multiplicative identity for Self.
Source§

fn is_one(&self) -> bool

Returns true if the value is the multiplicative identity.
Source§

impl<A, B> PartialEq<Quaternion<B>> for Quaternion<A>
where A: PartialEq<B>, Vector3<A>: PartialEq<Vector3<B>>,

Source§

fn eq(&self, other: &Quaternion<B>) -> 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<T> Rotation3 for Quaternion<T>
where T: Real + Clone + Zero + AddAssign,

Source§

type Scalar = T

Source§

fn invert(&self) -> Self

Returns the multiplicative inverse of the rotation. Effectively does the opposite of the given rotation.
Source§

fn rotate_vector(&self, v: Vector3<T>) -> Vector3<T>

Rotates a vector.
Source§

fn rotate_point(&self, p: Point3<Self::Scalar>) -> Point3<Self::Scalar>

Rotates a point around the origin.
Source§

impl<T> Serialize for Quaternion<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Sub for Quaternion<T>
where T: Sub<T, Output = T>,

Source§

type Output = Quaternion<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quaternion<T>) -> Self

Performs the - operation. Read more
Source§

impl<T> VectorSpace for Quaternion<T>
where T: Clone + Real + Zero,

Source§

type Scalar = T

Source§

fn lerp(self, other: Self, t: Self::Scalar) -> Self

Linear interpolate between the two vectors with a weight of t.
Source§

impl<T> Zero for Quaternion<T>
where T: Zero,

Source§

fn zero() -> Self

Returns the additive identity of Self.
Source§

fn is_zero(&self) -> bool

Returns true if the value is the additive identity.
Source§

impl<T: Copy> Copy for Quaternion<T>

Source§

impl<T> Eq for Quaternion<T>
where T: Eq,

Auto Trait Implementations§

§

impl<T> Freeze for Quaternion<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Quaternion<T>
where T: RefUnwindSafe,

§

impl<T> Send for Quaternion<T>
where T: Send,

§

impl<T> Sync for Quaternion<T>
where T: Sync,

§

impl<T> Unpin for Quaternion<T>
where T: Unpin,

§

impl<T> UnwindSafe for Quaternion<T>
where T: UnwindSafe,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,