Struct spectra::linear::Quaternion
[−]
[src]
#[repr(C)]pub struct Quaternion<S> { pub s: S, pub v: Vector3<S>, }
A quaternion in scalar/vector form.
This type is marked as #[repr(C)]
.
Fields
s: S
The scalar part of the quaternion.
v: Vector3<S>
The vector part of the quaternion.
Methods
impl<S> Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn new(w: S, xi: S, yj: S, zk: S) -> Quaternion<S>
Construct a new quaternion from one scalar component and three imaginary components.
fn from_sv(s: S, v: Vector3<S>) -> Quaternion<S>
Construct a new quaternion from a scalar and a vector.
fn from_arc(
src: Vector3<S>,
dst: Vector3<S>,
fallback: Option<Vector3<S>>
) -> Quaternion<S>
src: Vector3<S>,
dst: Vector3<S>,
fallback: Option<Vector3<S>>
) -> Quaternion<S>
Construct a new quaternion as a closest arc between two vectors
Return the closest rotation that turns src
vector into dst
.
fn conjugate(self) -> Quaternion<S>
The conjugate of the quaternion.
fn nlerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>
Do a normalized linear interpolation with other
, by amount
.
fn slerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>
Spherical Linear Intoperlation
Return the spherical linear interpolation between the quaternion and
other
. Both quaternions should be normalized first.
Performance notes
The acos
operation used in slerp
is an expensive operation, so
unless your quarternions are far away from each other it's generally
more advisable to use nlerp
when you know your rotations are going
to be small.
Trait Implementations
impl<S> Index<usize> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Index<RangeTo<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Index<Range<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Index<RangeFrom<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Index<RangeFull> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Clone for Quaternion<S> where
S: Clone,
[src]
S: Clone,
fn clone(&self) -> Quaternion<S>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<S> Zero for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn zero() -> Quaternion<S>
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
Returns true
if self
is equal to the additive identity.
impl<S> MetricSpace for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Metric = S
fn distance2(self, other: Quaternion<S>) -> S
impl<S> Into<(S, S, S, S)> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Into<[S; 4]> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<'a, S> Product<&'a Quaternion<S>> for Quaternion<S> where
S: 'a + BaseFloat,
[src]
S: 'a + BaseFloat,
fn product<I>(iter: I) -> Quaternion<S> where
I: Iterator<Item = &'a Quaternion<S>>,
I: Iterator<Item = &'a Quaternion<S>>,
impl<S> Product<Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn product<I>(iter: I) -> Quaternion<S> where
I: Iterator<Item = Quaternion<S>>,
I: Iterator<Item = Quaternion<S>>,
impl<S> AsRef<[S; 4]> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> AsRef<(S, S, S, S)> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Copy for Quaternion<S> where
S: Copy,
[src]
S: Copy,
impl<'a, 'b, S> Add<&'a Quaternion<S>> for &'b Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the +
operator
fn add(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the +
operator
impl<'a, S> Add<&'a Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the +
operator
fn add(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the +
operator
impl<'a, S> Add<Quaternion<S>> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the +
operator
fn add(self, other: Quaternion<S>) -> Quaternion<S>
The method for the +
operator
impl<S> Add<Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the +
operator
fn add(self, other: Quaternion<S>) -> Quaternion<S>
The method for the +
operator
impl<'a, S> Div<S> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the /
operator
fn div(self, other: S) -> Quaternion<S>
The method for the /
operator
impl<S> Div<S> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the /
operator
fn div(self, other: S) -> Quaternion<S>
The method for the /
operator
impl<'a, S> Rem<S> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
fn rem(self, other: S) -> Quaternion<S>
impl<S> Rem<S> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
fn rem(self, other: S) -> Quaternion<S>
impl<S> ApproxEq for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Epsilon = <S as ApproxEq>::Epsilon
fn default_epsilon() -> <S as ApproxEq>::Epsilon
fn default_max_relative() -> <S as ApproxEq>::Epsilon
fn default_max_ulps() -> u32
fn relative_eq(
&self,
other: &Quaternion<S>,
epsilon: <S as ApproxEq>::Epsilon,
max_relative: <S as ApproxEq>::Epsilon
) -> bool
&self,
other: &Quaternion<S>,
epsilon: <S as ApproxEq>::Epsilon,
max_relative: <S as ApproxEq>::Epsilon
) -> bool
fn ulps_eq(
&self,
other: &Quaternion<S>,
epsilon: <S as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
&self,
other: &Quaternion<S>,
epsilon: <S as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
impl<S> Rotation3<S> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from_axis_angle<A>(axis: Vector3<S>, angle: A) -> Quaternion<S> where
A: Into<Rad<S>>,
A: Into<Rad<S>>,
impl<'a, 'b, S> Mul<&'a Vector3<S>> for &'b Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Vector3<S>
The resulting type after applying the *
operator
fn mul(self, other: &'a Vector3<S>) -> Vector3<S>
The method for the *
operator
impl<'a, S> Mul<Vector3<S>> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Vector3<S>
The resulting type after applying the *
operator
fn mul(self, other: Vector3<S>) -> Vector3<S>
The method for the *
operator
impl<'a, S> Mul<&'a Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the *
operator
impl<'a, S> Mul<Quaternion<S>> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: Quaternion<S>) -> Quaternion<S>
The method for the *
operator
impl<'a, S> Mul<S> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: S) -> Quaternion<S>
The method for the *
operator
impl<S> Mul<Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: Quaternion<S>) -> Quaternion<S>
The method for the *
operator
impl<'a, S> Mul<&'a Vector3<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Vector3<S>
The resulting type after applying the *
operator
fn mul(self, other: &'a Vector3<S>) -> Vector3<S>
The method for the *
operator
impl<'a, 'b, S> Mul<&'a Quaternion<S>> for &'b Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the *
operator
impl<S> Mul<Vector3<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Vector3<S>
The resulting type after applying the *
operator
fn mul(self, other: Vector3<S>) -> Vector3<S>
The method for the *
operator
impl<S> Mul<S> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the *
operator
fn mul(self, other: S) -> Quaternion<S>
The method for the *
operator
impl<S> InnerSpace for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn dot(self, other: Quaternion<S>) -> S
Vector dot (or inner) product.
fn is_perpendicular(self, other: Self) -> bool
Returns true
if the vector is perpendicular (at right angles) to the other vector. Read more
fn magnitude2(self) -> Self::Scalar
Returns the squared magnitude. Read more
fn magnitude(self) -> Self::Scalar
The distance from the tail to the tip of the vector.
fn angle(self, other: Self) -> Rad<Self::Scalar>
Returns the angle between two vectors in radians.
fn normalize(self) -> Self
Returns a vector with the same direction, but with a magnitude of 1
.
fn normalize_to(self, magnitude: Self::Scalar) -> Self
Returns a vector with the same direction and a given magnitude.
fn lerp(self, other: Self, amount: Self::Scalar) -> Self
Returns the result of linearly interpolating the magnitude of the vector towards the magnitude of other
by the specified amount. Read more
impl<S> IndexMut<RangeFrom<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn index_mut(&'a mut self, i: RangeFrom<usize>) -> &'a mut [S]
impl<S> IndexMut<usize> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> IndexMut<Range<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn index_mut(&'a mut self, i: Range<usize>) -> &'a mut [S]
impl<S> IndexMut<RangeFull> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn index_mut(&'a mut self, i: RangeFull) -> &'a mut [S]
impl<S> IndexMut<RangeTo<usize>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn index_mut(&'a mut self, i: RangeTo<usize>) -> &'a mut [S]
impl<S> VectorSpace for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Scalar = S
impl<S> Sum<Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn sum<I>(iter: I) -> Quaternion<S> where
I: Iterator<Item = Quaternion<S>>,
I: Iterator<Item = Quaternion<S>>,
impl<'a, S> Sum<&'a Quaternion<S>> for Quaternion<S> where
S: 'a + BaseFloat,
[src]
S: 'a + BaseFloat,
fn sum<I>(iter: I) -> Quaternion<S> where
I: Iterator<Item = &'a Quaternion<S>>,
I: Iterator<Item = &'a Quaternion<S>>,
impl<S> DivAssign<S> for Quaternion<S> where
S: BaseFloat + DivAssign<S>,
[src]
S: BaseFloat + DivAssign<S>,
fn div_assign(&mut self, scalar: S)
impl<S> PartialEq<Quaternion<S>> for Quaternion<S> where
S: PartialEq<S>,
[src]
S: PartialEq<S>,
fn eq(&self, __arg_0: &Quaternion<S>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Quaternion<S>) -> bool
This method tests for !=
.
impl<S> MulAssign<S> for Quaternion<S> where
S: BaseFloat + MulAssign<S>,
[src]
S: BaseFloat + MulAssign<S>,
fn mul_assign(&mut self, scalar: S)
impl<S> AddAssign<Quaternion<S>> for Quaternion<S> where
S: BaseFloat + AddAssign<S>,
[src]
S: BaseFloat + AddAssign<S>,
fn add_assign(&mut self, other: Quaternion<S>)
impl<'a, S> Sub<Quaternion<S>> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the -
operator
fn sub(self, other: Quaternion<S>) -> Quaternion<S>
The method for the -
operator
impl<'a, S> Sub<&'a Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the -
operator
fn sub(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the -
operator
impl<'a, 'b, S> Sub<&'a Quaternion<S>> for &'b Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the -
operator
fn sub(self, other: &'a Quaternion<S>) -> Quaternion<S>
The method for the -
operator
impl<S> Sub<Quaternion<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
The resulting type after applying the -
operator
fn sub(self, other: Quaternion<S>) -> Quaternion<S>
The method for the -
operator
impl<S> Rotation<Point3<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn look_at(dir: Vector3<S>, up: Vector3<S>) -> Quaternion<S>
Create a rotation to a given direction with an 'up' vector.
fn between_vectors(a: Vector3<S>, b: Vector3<S>) -> Quaternion<S>
Create a shortest rotation to transform vector 'a' into 'b'. Both given vectors are assumed to have unit length. Read more
fn rotate_vector(&self, vec: Vector3<S>) -> Vector3<S>
Rotate a vector using this rotation.
fn invert(&self) -> Quaternion<S>
Create a new rotation which "un-does" this rotation. That is, r * r.invert()
is the identity. Read more
fn rotate_point(&self, point: P) -> P
Rotate a point using this rotation, by converting it to its representation as a vector. Read more
impl<'a, S> From<&'a (S, S, S, S)> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: &'a (S, S, S, S)) -> &'a Quaternion<S>
Performs the conversion.
impl<S> From<[S; 4]> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: [S; 4]) -> Quaternion<S>
Performs the conversion.
impl<S> From<(S, S, S, S)> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: (S, S, S, S)) -> Quaternion<S>
Performs the conversion.
impl<A> From<Euler<A>> for Quaternion<<A as Angle>::Unitless> where
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
[src]
A: Angle + Into<Rad<<A as Angle>::Unitless>>,
fn from(src: Euler<A>) -> Quaternion<<A as Angle>::Unitless>
Performs the conversion.
impl<'a, S> From<&'a [S; 4]> for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: &'a [S; 4]) -> &'a Quaternion<S>
Performs the conversion.
impl<'a, S> From<&'a mut (S, S, S, S)> for &'a mut Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: &'a mut (S, S, S, S)) -> &'a mut Quaternion<S>
Performs the conversion.
impl<S> From<Matrix3<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(mat: Matrix3<S>) -> Quaternion<S>
Convert the matrix to a quaternion
impl<S> From<Basis3<S>> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(b: Basis3<S>) -> Quaternion<S>
Performs the conversion.
impl<'a, S> From<&'a mut [S; 4]> for &'a mut Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn from(v: &'a mut [S; 4]) -> &'a mut Quaternion<S>
Performs the conversion.
impl<S> Rand for Quaternion<S> where
S: BaseFloat + Rand,
[src]
S: BaseFloat + Rand,
fn rand<R>(rng: &mut R) -> Quaternion<S> where
R: Rng,
R: Rng,
impl<S> AsMut<[S; 4]> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> AsMut<(S, S, S, S)> for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> RemAssign<S> for Quaternion<S> where
S: BaseFloat + RemAssign<S>,
[src]
S: BaseFloat + RemAssign<S>,
fn rem_assign(&mut self, scalar: S)
impl<S> SubAssign<Quaternion<S>> for Quaternion<S> where
S: BaseFloat + SubAssign<S>,
[src]
S: BaseFloat + SubAssign<S>,
fn sub_assign(&mut self, other: Quaternion<S>)
impl<S> One for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
fn one() -> Quaternion<S>
Returns the multiplicative identity element of Self
, 1
. Read more
impl<S> Neg for Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
fn neg(self) -> Quaternion<S>
impl<'a, S> Neg for &'a Quaternion<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Quaternion<S>
fn neg(self) -> Quaternion<S>
impl<S> Debug for Quaternion<S> where
S: Debug,
[src]
S: Debug,