[−][src]Struct cgmath::Quaternion
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>
[src]
pub const fn new(w: S, xi: S, yj: S, zk: S) -> Quaternion<S>
[src]
Construct a new quaternion from one scalar component and three imaginary components.
pub const fn from_sv(s: S, v: Vector3<S>) -> Quaternion<S>
[src]
Construct a new quaternion from a scalar and a vector.
impl<S: BaseFloat> Quaternion<S>
[src]
pub fn from_arc(
src: Vector3<S>,
dst: Vector3<S>,
fallback: Option<Vector3<S>>
) -> Quaternion<S>
[src]
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
.
- [Related StackOverflow question] (http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another)
- [Ogre implementation for normalized vectors] (https://bitbucket.org/sinbad/ogre/src/9db75e3ba05c/OgreMain/include/OgreVector3.h?fileviewer=file-view-default#cl-651)
pub fn conjugate(self) -> Quaternion<S>
[src]
The conjugate of the quaternion.
pub fn nlerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>
[src]
Do a normalized linear interpolation with other
, by amount
.
pub fn slerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>
[src]
Spherical Linear Interpolation
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 quaternions are far away from each other it's generally
more advisable to use nlerp
when you know your rotations are going
to be small.
- [Understanding Slerp, Then Not Using It] (http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/)
- [Arcsynthesis OpenGL tutorial] (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html)
pub fn is_finite(&self) -> bool
[src]
impl<S: NumCast + Copy> Quaternion<S>
[src]
pub fn cast<T: BaseFloat>(&self) -> Option<Quaternion<T>>
[src]
Component-wise casting to another type.
Trait Implementations
impl<S: BaseFloat> VectorSpace for Quaternion<S>
[src]
impl<S: BaseFloat> MetricSpace for Quaternion<S>
[src]
type Metric = S
The metric to be returned by the distance
function.
fn distance2(self, other: Self) -> S
[src]
fn distance(self, other: Self) -> Self::Metric
[src]
impl<S: BaseFloat> InnerSpace for Quaternion<S>
[src]
fn dot(self, other: Quaternion<S>) -> S
[src]
fn is_perpendicular(self, other: Self) -> bool
[src]
fn magnitude2(self) -> Self::Scalar
[src]
fn magnitude(self) -> Self::Scalar
[src]
fn angle(self, other: Self) -> Rad<Self::Scalar>
[src]
fn normalize(self) -> Self
[src]
fn normalize_to(self, magnitude: Self::Scalar) -> Self
[src]
fn project_on(self, other: Self) -> Self
[src]
impl<S: BaseFloat> Rotation<Point3<S>> for Quaternion<S>
[src]
fn look_at(dir: Vector3<S>, up: Vector3<S>) -> Quaternion<S>
[src]
fn between_vectors(a: Vector3<S>, b: Vector3<S>) -> Quaternion<S>
[src]
fn rotate_vector(&self, vec: Vector3<S>) -> Vector3<S>
[src]
fn invert(&self) -> Quaternion<S>
[src]
fn rotate_point(&self, point: P) -> P
[src]
impl<S: BaseFloat> Rotation3<S> for Quaternion<S>
[src]
fn from_axis_angle<A: Into<Rad<S>>>(axis: Vector3<S>, angle: A) -> Quaternion<S>
[src]
fn from_angle_x<A: Into<Rad<S>>>(theta: A) -> Self
[src]
fn from_angle_y<A: Into<Rad<S>>>(theta: A) -> Self
[src]
fn from_angle_z<A: Into<Rad<S>>>(theta: A) -> Self
[src]
impl<S: BaseFloat> Into<[S; 4]> for Quaternion<S>
[src]
impl<S: BaseFloat> Into<(S, S, S, S)> for Quaternion<S>
[src]
impl<S: BaseFloat> AsMut<[S; 4]> for Quaternion<S>
[src]
impl<S: BaseFloat> AsMut<(S, S, S, S)> for Quaternion<S>
[src]
impl<S: Clone> Clone for Quaternion<S>
[src]
fn clone(&self) -> Quaternion<S>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S: BaseFloat> AsRef<[S; 4]> for Quaternion<S>
[src]
impl<S: BaseFloat> AsRef<(S, S, S, S)> for Quaternion<S>
[src]
impl<S: PartialEq> PartialEq<Quaternion<S>> for Quaternion<S>
[src]
fn eq(&self, other: &Quaternion<S>) -> bool
[src]
fn ne(&self, other: &Quaternion<S>) -> bool
[src]
impl<S: BaseFloat> From<Matrix3<S>> for Quaternion<S>
[src]
fn from(mat: Matrix3<S>) -> Quaternion<S>
[src]
Convert the matrix to a quaternion
impl<A> From<Euler<A>> for Quaternion<A::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::Unitless>
[src]
impl<S: BaseFloat> From<Quaternion<S>> for Matrix3<S>
[src]
fn from(quat: Quaternion<S>) -> Matrix3<S>
[src]
Convert the quaternion to a 3 x 3 rotation matrix.
impl<S: BaseFloat> From<Quaternion<S>> for Matrix4<S>
[src]
fn from(quat: Quaternion<S>) -> Matrix4<S>
[src]
Convert the quaternion to a 4 x 4 rotation matrix.
impl<S: BaseFloat> From<Quaternion<S>> for Basis3<S>
[src]
fn from(quat: Quaternion<S>) -> Basis3<S>
[src]
impl<S: BaseFloat> From<[S; 4]> for Quaternion<S>
[src]
fn from(v: [S; 4]) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> From<&'a [S; 4]> for &'a Quaternion<S>
[src]
fn from(v: &'a [S; 4]) -> &'a Quaternion<S>
[src]
impl<'a, S: BaseFloat> From<&'a mut [S; 4]> for &'a mut Quaternion<S>
[src]
fn from(v: &'a mut [S; 4]) -> &'a mut Quaternion<S>
[src]
impl<S: BaseFloat> From<(S, S, S, S)> for Quaternion<S>
[src]
fn from(v: (S, S, S, S)) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> From<&'a (S, S, S, S)> for &'a Quaternion<S>
[src]
fn from(v: &'a (S, S, S, S)) -> &'a Quaternion<S>
[src]
impl<'a, S: BaseFloat> From<&'a mut (S, S, S, S)> for &'a mut Quaternion<S>
[src]
fn from(v: &'a mut (S, S, S, S)) -> &'a mut Quaternion<S>
[src]
impl<S: BaseFloat> From<Quaternion<S>> for Euler<Rad<S>>
[src]
fn from(src: Quaternion<S>) -> Euler<Rad<S>>
[src]
impl<S: BaseFloat> From<Basis3<S>> for Quaternion<S>
[src]
fn from(b: Basis3<S>) -> Quaternion<S>
[src]
impl<S: Copy> Copy for Quaternion<S>
[src]
impl<S: BaseFloat> Add<Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the +
operator.
fn add(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Add<&'a Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the +
operator.
fn add(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Add<Quaternion<S>> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the +
operator.
fn add(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, 'b, S: BaseFloat> Add<&'a Quaternion<S>> for &'b Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the +
operator.
fn add(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl<S: BaseFloat> Sub<Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn sub(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Sub<&'a Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn sub(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Sub<Quaternion<S>> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn sub(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, 'b, S: BaseFloat> Sub<&'a Quaternion<S>> for &'b Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn sub(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl<S: BaseFloat> Mul<S> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: S) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Mul<S> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: S) -> Quaternion<S>
[src]
impl<S: BaseFloat> Mul<Vector3<S>> for Quaternion<S>
[src]
type Output = Vector3<S>
The resulting type after applying the *
operator.
fn mul(self, other: Vector3<S>) -> Vector3<S>
[src]
impl<'a, S: BaseFloat> Mul<&'a Vector3<S>> for Quaternion<S>
[src]
type Output = Vector3<S>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Vector3<S>) -> Vector3<S>
[src]
impl<'a, S: BaseFloat> Mul<Vector3<S>> for &'a Quaternion<S>
[src]
type Output = Vector3<S>
The resulting type after applying the *
operator.
fn mul(self, other: Vector3<S>) -> Vector3<S>
[src]
impl<'a, 'b, S: BaseFloat> Mul<&'a Vector3<S>> for &'b Quaternion<S>
[src]
type Output = Vector3<S>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Vector3<S>) -> Vector3<S>
[src]
impl<S: BaseFloat> Mul<Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Mul<&'a Quaternion<S>> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Mul<Quaternion<S>> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: Quaternion<S>) -> Quaternion<S>
[src]
impl<'a, 'b, S: BaseFloat> Mul<&'a Quaternion<S>> for &'b Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Quaternion<S>) -> Quaternion<S>
[src]
impl Mul<Quaternion<f32>> for f32
[src]
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
fn mul(self, other: Quaternion<f32>) -> Quaternion<f32>
[src]
impl<'a> Mul<&'a Quaternion<f32>> for f32
[src]
type Output = Quaternion<f32>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Quaternion<f32>) -> Quaternion<f32>
[src]
impl Mul<Quaternion<f64>> for f64
[src]
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
fn mul(self, other: Quaternion<f64>) -> Quaternion<f64>
[src]
impl<'a> Mul<&'a Quaternion<f64>> for f64
[src]
type Output = Quaternion<f64>
The resulting type after applying the *
operator.
fn mul(self, other: &'a Quaternion<f64>) -> Quaternion<f64>
[src]
impl<S: BaseFloat> Div<S> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the /
operator.
fn div(self, other: S) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Div<S> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the /
operator.
fn div(self, other: S) -> Quaternion<S>
[src]
impl Div<Quaternion<f32>> for f32
[src]
type Output = Quaternion<f32>
The resulting type after applying the /
operator.
fn div(self, other: Quaternion<f32>) -> Quaternion<f32>
[src]
impl<'a> Div<&'a Quaternion<f32>> for f32
[src]
type Output = Quaternion<f32>
The resulting type after applying the /
operator.
fn div(self, other: &'a Quaternion<f32>) -> Quaternion<f32>
[src]
impl Div<Quaternion<f64>> for f64
[src]
type Output = Quaternion<f64>
The resulting type after applying the /
operator.
fn div(self, other: Quaternion<f64>) -> Quaternion<f64>
[src]
impl<'a> Div<&'a Quaternion<f64>> for f64
[src]
type Output = Quaternion<f64>
The resulting type after applying the /
operator.
fn div(self, other: &'a Quaternion<f64>) -> Quaternion<f64>
[src]
impl<S: BaseFloat> Rem<S> for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the %
operator.
fn rem(self, other: S) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Rem<S> for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the %
operator.
fn rem(self, other: S) -> Quaternion<S>
[src]
impl<S: BaseFloat> Neg for Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn neg(self) -> Quaternion<S>
[src]
impl<'a, S: BaseFloat> Neg for &'a Quaternion<S>
[src]
type Output = Quaternion<S>
The resulting type after applying the -
operator.
fn neg(self) -> Quaternion<S>
[src]
impl<S: BaseFloat + AddAssign<S>> AddAssign<Quaternion<S>> for Quaternion<S>
[src]
fn add_assign(&mut self, other: Quaternion<S>)
[src]
impl<S: BaseFloat + SubAssign<S>> SubAssign<Quaternion<S>> for Quaternion<S>
[src]
fn sub_assign(&mut self, other: Quaternion<S>)
[src]
impl<S: BaseFloat + MulAssign<S>> MulAssign<S> for Quaternion<S>
[src]
fn mul_assign(&mut self, scalar: S)
[src]
impl<S: BaseFloat + DivAssign<S>> DivAssign<S> for Quaternion<S>
[src]
fn div_assign(&mut self, scalar: S)
[src]
impl<S: BaseFloat + RemAssign<S>> RemAssign<S> for Quaternion<S>
[src]
fn rem_assign(&mut self, scalar: S)
[src]
impl<S: BaseFloat> Index<usize> for Quaternion<S>
[src]
impl<S: BaseFloat> Index<Range<usize>> for Quaternion<S>
[src]
type Output = [S]
The returned type after indexing.
fn index<'a>(&'a self, i: Range<usize>) -> &'a [S]
[src]
impl<S: BaseFloat> Index<RangeTo<usize>> for Quaternion<S>
[src]
type Output = [S]
The returned type after indexing.
fn index<'a>(&'a self, i: RangeTo<usize>) -> &'a [S]
[src]
impl<S: BaseFloat> Index<RangeFrom<usize>> for Quaternion<S>
[src]
type Output = [S]
The returned type after indexing.
fn index<'a>(&'a self, i: RangeFrom<usize>) -> &'a [S]
[src]
impl<S: BaseFloat> Index<RangeFull> for Quaternion<S>
[src]
type Output = [S]
The returned type after indexing.
fn index<'a>(&'a self, i: RangeFull) -> &'a [S]
[src]
impl<S: BaseFloat> IndexMut<usize> for Quaternion<S>
[src]
impl<S: BaseFloat> IndexMut<Range<usize>> for Quaternion<S>
[src]
fn index_mut<'a>(&'a mut self, i: Range<usize>) -> &'a mut [S]
[src]
impl<S: BaseFloat> IndexMut<RangeTo<usize>> for Quaternion<S>
[src]
fn index_mut<'a>(&'a mut self, i: RangeTo<usize>) -> &'a mut [S]
[src]
impl<S: BaseFloat> IndexMut<RangeFrom<usize>> for Quaternion<S>
[src]
fn index_mut<'a>(&'a mut self, i: RangeFrom<usize>) -> &'a mut [S]
[src]
impl<S: BaseFloat> IndexMut<RangeFull> for Quaternion<S>
[src]
fn index_mut<'a>(&'a mut self, i: RangeFull) -> &'a mut [S]
[src]
impl<S: Debug> Debug for Quaternion<S>
[src]
impl<S: BaseFloat> Product<Quaternion<S>> for Quaternion<S>
[src]
fn product<I: Iterator<Item = Quaternion<S>>>(iter: I) -> Quaternion<S>
[src]
impl<'a, S: 'a + BaseFloat> Product<&'a Quaternion<S>> for Quaternion<S>
[src]
fn product<I: Iterator<Item = &'a Quaternion<S>>>(iter: I) -> Quaternion<S>
[src]
impl<S: BaseFloat> Sum<Quaternion<S>> for Quaternion<S>
[src]
fn sum<I: Iterator<Item = Quaternion<S>>>(iter: I) -> Quaternion<S>
[src]
impl<'a, S: 'a + BaseFloat> Sum<&'a Quaternion<S>> for Quaternion<S>
[src]
fn sum<I: Iterator<Item = &'a Quaternion<S>>>(iter: I) -> Quaternion<S>
[src]
impl<S: BaseFloat> AbsDiffEq<Quaternion<S>> for Quaternion<S>
[src]
type Epsilon = S::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> S::Epsilon
[src]
fn abs_diff_eq(&self, other: &Self, epsilon: S::Epsilon) -> bool
[src]
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
[src]
impl<S: BaseFloat> RelativeEq<Quaternion<S>> for Quaternion<S>
[src]
fn default_max_relative() -> S::Epsilon
[src]
fn relative_eq(
&self,
other: &Self,
epsilon: S::Epsilon,
max_relative: S::Epsilon
) -> bool
[src]
&self,
other: &Self,
epsilon: S::Epsilon,
max_relative: S::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<S: BaseFloat> UlpsEq<Quaternion<S>> for Quaternion<S>
[src]
fn default_max_ulps() -> u32
[src]
fn ulps_eq(&self, other: &Self, epsilon: S::Epsilon, max_ulps: u32) -> bool
[src]
fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
impl<S: BaseFloat> Zero for Quaternion<S>
[src]
impl<S: BaseFloat> One for Quaternion<S>
[src]
fn one() -> Quaternion<S>
[src]
fn set_one(&mut self)
[src]
fn is_one(&self) -> bool where
Self: PartialEq<Self>,
[src]
Self: PartialEq<Self>,
impl<S> Distribution<Quaternion<S>> for Standard where
Standard: Distribution<S>,
Standard: Distribution<Vector3<S>>,
S: BaseFloat,
[src]
Standard: Distribution<S>,
Standard: Distribution<Vector3<S>>,
S: BaseFloat,
Auto Trait Implementations
impl<S> Send for Quaternion<S> where
S: Send,
S: Send,
impl<S> Unpin for Quaternion<S> where
S: Unpin,
S: Unpin,
impl<S> Sync for Quaternion<S> where
S: Sync,
S: Sync,
impl<S> UnwindSafe for Quaternion<S> where
S: UnwindSafe,
S: UnwindSafe,
impl<S> RefUnwindSafe for Quaternion<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
[src]
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,