pub struct Quaternion<T> {
pub w: T,
pub x: T,
pub y: T,
pub z: T,
}
Expand description
Quaternion type.
We follow the naming conventions from
Wikipedia for quaternions.
You can generate quaternions using the new
function:
// 1 + 2i + 3j + 4k
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
Alternatively, you can construct quaternions directly with the member data fields:
let q = Q32 { w: 1.0, x: 2.0, y: 3.0, z: 4.0 };
This is exactly equivalent to the first method. The latter example uses the
shorthand Q32
for Quaternion<f32>
. For your convenience, there are also
the member constants ONE
, I
,
J
, and K
for the mathematical
values $1$, $i$, $j$, and $k$, respectively.
Quaternion
s support the usual arithmetic operations of addition,
subtraction, multiplication, and division. You can compute the
norm with norm
or fast_norm
and its square with norm_sqr
. Quaternion
conjugation is done by the member function conj
.
You can normalize a quaternion by calling
normalize
, which returns a UnitQuaternion
.
Furthermore, the following functions are supported:
dot
: Computes the dot product of two quaternions.exp
: Computes the exponential of a quaternion.expf
: Raises a real value to a quaternion power.inv
: Computes the multiplicative inverse.ln
: Computes the natural logarithm of a quaternion.powf
: Raises a quaternion to a real power.powi
: Raises a quaternion to a signed integer power.powu
: Raises a quaternion to an unsigned integer power.
To work with rotations, please use UnitQuaternion
s.
§Examples
Basic usage:
let q1 = Quaternion::new(1.0f32, 0.0, 0.0, 0.0);
let q2 = Quaternion::new(0.0, 1.0, 0.0, 0.0);
let q3 = q1 + q2;
assert_eq!(q3, Quaternion::new(1.0, 1.0, 0.0, 0.0));
§Fields
w
: Real part of the quaternion.x
: The coefficient of $i$.y
: The coefficient of $j$.z
: The coefficient of $k$.
Fields§
§w: T
Real part of the quaternion.
x: T
The coefficient of $i$.
y: T
The coefficient of $j$.
z: T
The coefficient of $k$.
Implementations§
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Source§impl<T> Quaternion<T>where
T: ConstZero,
impl<T> Quaternion<T>where
T: ConstZero,
Sourcepub const ZERO: Self
pub const ZERO: Self
A constant zero Quaternion
.
This is the additive identity element of the quaternion space.
See also Quaternion::zero
.
§Example
let q = Quaternion::ZERO;
assert_eq!(q, Quaternion::new(0.0f32, 0.0, 0.0, 0.0));
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Sourcepub const ONE: Self
pub const ONE: Self
A constant Quaternion
of value $1$.
See also Quaternion::one
.
§Example
let q = Quaternion::ONE;
assert_eq!(q, Quaternion::new(1.0f32, 0.0, 0.0, 0.0));
Sourcepub const I: Self
pub const I: Self
A constant Quaternion
of value $i$.
See also Quaternion::i
.
§Example
let q = Quaternion::I;
assert_eq!(q, Quaternion::new(0.0f32, 1.0, 0.0, 0.0));
Sourcepub const J: Self
pub const J: Self
A constant Quaternion
of value $j$.
See also Quaternion::j
.
§Example
let q = Quaternion::J;
assert_eq!(q, Quaternion::new(0.0f32, 0.0, 1.0, 0.0));
Sourcepub const K: Self
pub const K: Self
A constant Quaternion
of value $k$.
See also Quaternion::k
.
§Example
let q = Quaternion::K;
assert_eq!(q, Quaternion::new(0.0f32, 0.0, 0.0, 1.0));
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Sourcepub fn one() -> Self
pub fn one() -> Self
Returns the real unit $1$.
See also Quaternion::ONE
.
§Example
let q = Quaternion::one();
assert_eq!(q, Quaternion::new(1.0f32, 0.0, 0.0, 0.0));
Sourcepub fn i() -> Self
pub fn i() -> Self
Returns the imaginary unit $i$.
See also Quaternion::I
.
§Example
let q = Quaternion::i();
assert_eq!(q, Quaternion::new(0.0f32, 1.0, 0.0, 0.0));
Sourcepub fn j() -> Self
pub fn j() -> Self
Returns the imaginary unit $j$.
See also Quaternion::J
.
§Example
let q = Quaternion::j();
assert_eq!(q, Quaternion::new(0.0f32, 0.0, 1.0, 0.0));
Sourcepub fn k() -> Self
pub fn k() -> Self
Returns the imaginary unit $k$.
See also Quaternion::K
.
§Example
let q = Quaternion::k();
assert_eq!(q, Quaternion::new(0.0f32, 0.0, 0.0, 1.0));
Source§impl<T> Quaternion<T>where
T: Float,
impl<T> Quaternion<T>where
T: Float,
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Sourcepub fn norm_sqr(&self) -> T
pub fn norm_sqr(&self) -> T
Returns the square of the norm.
The result is $w^2 + x^2 + y^2 + z^2$ with some rounding errors. The rounding error is at most 2 ulps.
This is guaranteed to be more efficient than norm
.
Furthermore, T
only needs to support addition and multiplication
and therefore, this function works for more types than
norm
.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert_eq!(q.norm_sqr(), 30.0);
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Source§impl<T> Quaternion<T>where
for<'a> &'a Self: Inv<Output = Quaternion<T>>,
impl<T> Quaternion<T>where
for<'a> &'a Self: Inv<Output = Quaternion<T>>,
Source§impl<T> Quaternion<T>where
T: Float,
impl<T> Quaternion<T>where
T: Float,
Sourcepub fn norm(self) -> T
pub fn norm(self) -> T
Calculates |self|.
The result is $\sqrt{w^2+x^2+y^2+z^2}$ with some possible rounding errors. The total relative rounding error is at most two ulps.
If any of the components of the input quaternion is NaN
, then NaN
is returned. Otherwise, if any of the components is infinite, then
a positive infinite value is returned.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert_eq!(q.norm(), 30.0f32.sqrt());
Source§impl<T> Quaternion<T>where
T: Float,
impl<T> Quaternion<T>where
T: Float,
Sourcepub fn fast_norm(self) -> T
pub fn fast_norm(self) -> T
Calculates |self| without branching.
This function returns the same result as norm
, if
|self|² is a normal floating point number (i. e. there is no overflow
nor underflow), or if self
is zero. In these cases the maximum
relative error of the result is guaranteed to be less than two ulps.
In all other cases, there’s no guarantee on the precision of the
result:
- If |self|² overflows, then $\infty$ is returned.
- If |self|² underflows to zero, then zero will be returned.
- If |self|² is a subnormal number (very small floating point value with reduced relative precision), then the result is the square root of that.
In other words, this function can be imprecise for very large and very
small floating point numbers, but it is generally faster than
norm
, because it does not do any branching. So if you
are interested in maximum speed of your code, feel free to use this
function. If you need to be precise results for the whole range of the
floating point type T
, stay with norm
.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert_eq!(q.fast_norm(), q.norm());
Source§impl<T> Quaternion<T>where
T: Float,
impl<T> Quaternion<T>where
T: Float,
Sourcepub fn normalize(self) -> Option<UnitQuaternion<T>>
pub fn normalize(self) -> Option<UnitQuaternion<T>>
Normalizes the quaternion to length $1$.
The sign of the real part will be the same as the sign of the input. If the input quaternion
- is zero, or
- has infinite length, or
- has a
NaN
value,
then None
will be returned.
§Example
let q = Quaternion::new(1.0f32, 2.0, 2.0, 4.0);
assert_eq!(q.normalize()?.into_quaternion(),
Quaternion::new(0.2f32, 0.4, 0.4, 0.8));
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Source§impl<T> Quaternion<T>
impl<T> Quaternion<T>
Source§impl<T> Quaternion<T>where
T: Float + FloatConst,
impl<T> Quaternion<T>where
T: Float + FloatConst,
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
Given a quaternion $q$, returns $e^q$, where $e$ is the base of the natural logarithm.
This method computes the exponential of a quaternion, handling various edge cases to ensure numerical stability and correctness:
-
Negative Real Part: If the real part is sufficiently negative, such that $e^{\Re q}$ is approximately zero, the method returns zero. This is done even if the imaginary part contains infinite or NaN values.
-
NaN Input: If any component of the input quaternion is
NaN
, the method returns a quaternion filled withNaN
values. -
Large Imaginary Norm: If the norm of the imaginary part is too large, the method may return a
NaN
quaternion or a quaternion with the correct magnitude but inaccurate direction. -
Infinite Result: If $e^{\Re q}$ results in
+∞
, the method computes the direction and returns an infinite quaternion in that direction, ensuring that∞ * 0
values are mapped to zero instead ofNaN
. -
Finite Norm: For finite norms, the method ensures a very small relative error in all components, depending on the accuracy of the underlying floating point function implementations.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
let exp_q = q.exp();
Source§impl<T> Quaternion<T>where
T: Float + FloatConst,
impl<T> Quaternion<T>where
T: Float + FloatConst,
Sourcepub fn expf(self, base: T) -> Self
pub fn expf(self, base: T) -> Self
Raises a real value (base
) to a quaternion (self
) power.
Given a quaternion $q$ and a real value $t$, this function computes $t^q := e^{q \ln t}$. The function handles special cases as follows:
- If $t = \pm 0$ and $\Re q > 0$, or $t = +\infty$ and $\Re q < 0$, a zero quaternion is returned.
- If $t < 0$ or $t$ is
NaN
, aNaN
quaternion (filled withNaN
values) is returned. - If $t$ is $+0$, $-0$, or $+\infty$ and $\Re q = 0$, a
NaN
quaternion is returned. - If $t = +\infty$ and $q$ is a positive real number, $+\infty$ is
returned. For other values of $q$ with $\Re q > 0$, a
NaN
quaternion is returned. - If $t = \pm 0$ and $q$ is a negative real number, $+\infty$ is
returned. For other values of $q$ with $\Re q < 0$, a
NaN
quaternion is returned.
For finite positive $t$, the following conventions for boundary values of $q$ are applied:
- If any component of $q$ is
NaN
or any imaginary component of $q$ is infinite, aNaN
quaternion is returned. - Otherwise, if $\Re q = -\infty$ and $t > 1$, a zero quaternion is returned.
- Otherwise, if $\Re q = +\infty$ and $0 < t < 1$, a zero quaternion is returned.
- Otherwise, if $\Re q$ is infinite and $t = 1$, a
NaN
quaternion is returned. - Otherwise, if $\Re q = +\infty$ and $t > 1$, an infinite quaternion
without
NaN
values is returned. - Otherwise, if $\Re q = -\infty$ and $0 < t < 1$, an infinite
quaternion without
NaN
values is returned.
If the true result’s norm is neither greater than the largest
representable floating point value nor less than the smallest
representable floating point value, and the direction of the output
quaternion cannot be accurately determined, a NaN
quaternion may or
may not be returned to indicate inaccuracy. This can occur when
$|\Im(q) \ln t|$ is on the order of $1/\varepsilon$, where
$\varepsilon$ is the machine precision of the floating point type used.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
let exp_q = q.expf(2.0);
Source§impl<T> Quaternion<T>where
T: Float + FloatConst,
impl<T> Quaternion<T>where
T: Float + FloatConst,
Sourcepub fn powf(self, exponent: T) -> Self
pub fn powf(self, exponent: T) -> Self
Raises a quaternion (self
) to a real value (exponent
) power.
Given a quaternion $q$ and a real value $t$, this function computes $q^t := e^{t \ln q}$. The function handles special cases as follows:
- If $q = 0$ and $t > 0$, a zero quaternion is returned.
- If $|q| = \infty$ and $t < 0$, a zero quaternion is returned.
- If $|q| = \infty$ and $t > 0$ is not too large to prevent
numerical accuracy for the direction of the quaternion, then an
infinite quaternion without
NaN
components is returned. For larger but finite values of $t$ this may still be hold, or alternatively a quaternion filled withNaN
values is returned. - If $q = +\infty$ and $t = +\infty$, then positive infinity is returned.
- If $|q| = \infty$, but $q \neq +\infty$ and $t = +\infty$, then
NaN
is returned. - If $q = 0$ and $t < 0$, then positive infinity is returned.
- If $q$ contains a
NaN
component, or if $t$ isNaN
, aNaN
quaternion is returned. - If $|q| = \infty$ and $t = 0$, a
NaN
quaternion is returned. - If $q = 0$ and $t = 0$, a
NaN
quaternion is returned.
For non-zero finite $q$, the following conventions for boundary values of $t$ are applied:
- If $t = +\infty$ and $q, |q| \ge 1$ is not real or $q = 1$ or
$q \le -1$, a
NaN
quaternion is returned. - If $t = +\infty$ and $q > 1$, positive infinity is returned.
- If $t = +\infty$ and $|q| < 1$, zero is returned.
- If $t = -\infty$ and $|q| > 1$, zero is returned.
- If $t = -\infty$ and $0 \le q < 1$, positive infinity is returned.
- If $t = -\infty$ and $q, |q| \le 1$ is not real or $q = 1$ or
$-1 \le q < 0$, a
NaN
quaternion is returned.
If the true result’s norm is neither greater than the largest
representable floating point value nor less than the smallest
representable floating point value, and the direction of the output
quaternion cannot be accurately determined, a NaN
quaternion may or
may not be returned to indicate inaccuracy. This can occur when
$|t \Im(\ln q)|$ is on the order of $1/\varepsilon$, where
$\varepsilon$ is the machine precision of the floating point type used.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
let exp_q = q.powf(2.0);
Source§impl<T> Quaternion<T>where
T: Float,
impl<T> Quaternion<T>where
T: Float,
Sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns whether all components of the quaternion are finite.
If a Quaternion
has an infinite or NaN
entry, the function returns
false
, otherwise true
.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert!(q.is_finite());
Sourcepub fn has_nan(&self) -> bool
pub fn has_nan(&self) -> bool
Returns whether any component of the quaternion is NaN
.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
assert!(!q.has_nan());
Sourcepub fn is_all_nan(&self) -> bool
pub fn is_all_nan(&self) -> bool
Returns whether all components of a quaternion are NaN
.
§Example
let q = Q64::nan();
assert!(q.is_all_nan());
Source§impl<T> Quaternion<T>where
T: Float + FloatConst,
impl<T> Quaternion<T>where
T: Float + FloatConst,
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
Computes the natural logarithm of a quaternion.
The function implements the following guarantees for extreme input values:
- The function is continuous onto the branch cut taking into account the sign of the coefficient of $i$.
- For all quaternions $q$ it holds
q.conj().ln() == q.ln().conj()
. - The signs of the coefficients of the imaginary parts of the outputs
are equal to the signs of the respective coefficients of the inputs.
This also holds for signs of zeros, but not for
NaNs
. - If $q = 0$, the result is $-\infty$. (The coefficients of $i$, $j$, and $k$ are zero with the original signs copied.)
- If the input has a
NaN
value, then the result isNaN
in all components. - Otherwise, if $q = w + xi + yj + zk$ where at least one of
$w, x, y, z$ is infinite, then the real part of the result is
$+\infty$ and the imaginary part is the imaginary part
of the logarithm of $f(w) + f(x)i + f(y)j + f(z)k$ where
- $f(+\infty) := 1$,
- $f(-\infty) :=-1$, and
- $f(s) := 0$ for finite values of $s$.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
let ln_q = q.ln();
Source§impl<T> Quaternion<T>where
T: Float + FloatConst,
impl<T> Quaternion<T>where
T: Float + FloatConst,
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Given the input quaternion $c$, this function returns the quaternion $q$ which satisfies $q^2 = c$ and has a real part with a positive sign.
For extreme values, the following guarantees are implemented:
- If any coefficient in $c$ is
NaN
, then the result isNaN
in all components. - Otherwise, for any input $c$, the expression
c.sqrt().conj()
is exactly equivalent toc.conj().sqrt()
, including the signs of zeros and infinities, if any. - For any input $c$,
c.sqrt().w
always has a positive sign. - For any input $c$, the signs of the three output imaginary parts are
the same as the input imaginary parts in their respective order,
except in the case of a
NaN
input. - For negative real inputs $c$, the result is $\pm\sqrt{-c} i$, where the sign is determined by the sign of the input’s coefficient of $i$.
- If there is at least one infinite coefficient in the imaginary part, then the result will have the same infinite imaginary coefficients and the real part is $+\infty$. All other coefficients of the result are $0$ with the sign of the respective input.
- If the real part is $-\infty$ and the imaginary part is finite, then the result is $\pm\infty i$ with the sign of the coefficient of $i$ from the input.
§Example
let q = Quaternion::new(1.0f32, 2.0, 3.0, 4.0);
let sqrt_q = q.sqrt();
Trait Implementations§
Source§impl<T> Add<&PureQuaternion<T>> for &Quaternion<T>
impl<T> Add<&PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<&PureQuaternion<T>> for Quaternion<T>
impl<T> Add<&PureQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<&Quaternion<T>> for &PureQuaternion<T>
impl<T> Add<&Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<&Quaternion<T>> for &Quaternion<T>
impl<T> Add<&Quaternion<T>> for &Quaternion<T>
Source§impl<T> Add<&Quaternion<T>> for &UnitQuaternion<T>
impl<T> Add<&Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<&Quaternion<T>> for PureQuaternion<T>
impl<T> Add<&Quaternion<T>> for PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<&Quaternion<T>> for Quaternion<T>
impl<T> Add<&Quaternion<T>> for Quaternion<T>
Source§impl<T> Add<&Quaternion<T>> for UnitQuaternion<T>
impl<T> Add<&Quaternion<T>> for UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<&T> for &Quaternion<T>
impl<T> Add<&T> for &Quaternion<T>
Source§impl<T> Add<&T> for Quaternion<T>
impl<T> Add<&T> for Quaternion<T>
Source§impl<T> Add<&UnitQuaternion<T>> for &Quaternion<T>
impl<T> Add<&UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<&UnitQuaternion<T>> for Quaternion<T>
impl<T> Add<&UnitQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<PureQuaternion<T>> for &Quaternion<T>
impl<T> Add<PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<PureQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<PureQuaternion<T>> for Quaternion<T>where
T: Add<T, Output = T>,
impl<T> Add<PureQuaternion<T>> for Quaternion<T>where
T: Add<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
+
operator.Source§impl<T> Add<Quaternion<T>> for &PureQuaternion<T>
impl<T> Add<Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<Quaternion<T>> for &Quaternion<T>
impl<T> Add<Quaternion<T>> for &Quaternion<T>
Source§impl<T> Add<Quaternion<T>> for &UnitQuaternion<T>
impl<T> Add<Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Add<Quaternion<T>>>::Output
+
operator.Source§impl<T> Add<Quaternion<T>> for PureQuaternion<T>where
T: Add<T, Output = T>,
impl<T> Add<Quaternion<T>> for PureQuaternion<T>where
T: Add<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
+
operator.Source§impl<T> Add<Quaternion<T>> for UnitQuaternion<T>
impl<T> Add<Quaternion<T>> for UnitQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
+
operator.Source§impl<T> Add<T> for &Quaternion<T>
impl<T> Add<T> for &Quaternion<T>
Source§impl<T> Add<T> for Quaternion<T>where
T: Add<T, Output = T>,
impl<T> Add<T> for Quaternion<T>where
T: Add<T, Output = T>,
Source§impl<T> Add<UnitQuaternion<T>> for &Quaternion<T>
impl<T> Add<UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Add<UnitQuaternion<T>>>::Output
+
operator.Source§impl<T> Add<UnitQuaternion<T>> for Quaternion<T>where
T: Add<T, Output = T>,
impl<T> Add<UnitQuaternion<T>> for Quaternion<T>where
T: Add<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
+
operator.Source§fn add(self, rhs: UnitQuaternion<T>) -> Self
fn add(self, rhs: UnitQuaternion<T>) -> Self
+
operation. Read moreSource§impl<T> Add for Quaternion<T>where
T: Add<T, Output = T>,
impl<T> Add for Quaternion<T>where
T: Add<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
+
operator.Source§impl<T, S> AddAssign<S> for Quaternion<T>
impl<T, S> AddAssign<S> for Quaternion<T>
Source§fn add_assign(&mut self, other: S)
fn add_assign(&mut self, other: S)
+=
operation. Read moreSource§impl<T> Borrow<Quaternion<T>> for UnitQuaternion<T>
impl<T> Borrow<Quaternion<T>> for UnitQuaternion<T>
Source§fn borrow(&self) -> &Quaternion<T>
fn borrow(&self) -> &Quaternion<T>
Source§impl<T: Clone> Clone for Quaternion<T>
impl<T: Clone> Clone for Quaternion<T>
Source§fn clone(&self) -> Quaternion<T>
fn clone(&self) -> Quaternion<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> ConstOne for Quaternion<T>
impl<T> ConstOne for Quaternion<T>
Source§impl<T> ConstZero for Quaternion<T>where
T: ConstZero,
impl<T> ConstZero for Quaternion<T>where
T: ConstZero,
Source§impl<T: Debug> Debug for Quaternion<T>
impl<T: Debug> Debug for Quaternion<T>
Source§impl<T: Default> Default for Quaternion<T>
impl<T: Default> Default for Quaternion<T>
Source§fn default() -> Quaternion<T>
fn default() -> Quaternion<T>
Source§impl<'de, T> Deserialize<'de> for Quaternion<T>where
T: Deserialize<'de>,
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>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T> Div<&PureQuaternion<T>> for &Quaternion<T>
impl<T> Div<&PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<&PureQuaternion<T>> for Quaternion<T>
impl<T> Div<&PureQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<&Quaternion<T>> for &PureQuaternion<T>
impl<T> Div<&Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<&Quaternion<T>> for &Quaternion<T>
impl<T> Div<&Quaternion<T>> for &Quaternion<T>
Source§impl<T> Div<&Quaternion<T>> for &UnitQuaternion<T>
impl<T> Div<&Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<&Quaternion<T>> for PureQuaternion<T>
impl<T> Div<&Quaternion<T>> for PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<&Quaternion<T>> for Quaternion<T>
impl<T> Div<&Quaternion<T>> for Quaternion<T>
Source§impl<T> Div<&Quaternion<T>> for UnitQuaternion<T>
impl<T> Div<&Quaternion<T>> for UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<&T> for &Quaternion<T>
impl<T> Div<&T> for &Quaternion<T>
Source§impl<T> Div<&T> for Quaternion<T>
impl<T> Div<&T> for Quaternion<T>
Source§impl<T> Div<&UnitQuaternion<T>> for &Quaternion<T>
impl<T> Div<&UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<&UnitQuaternion<T>> for Quaternion<T>
impl<T> Div<&UnitQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<PureQuaternion<T>> for &Quaternion<T>
impl<T> Div<PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<PureQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<PureQuaternion<T>> for Quaternion<T>
impl<T> Div<PureQuaternion<T>> for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
/
operator.Source§impl<T> Div<Quaternion<T>> for &PureQuaternion<T>
impl<T> Div<Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<Quaternion<T>> for &Quaternion<T>
impl<T> Div<Quaternion<T>> for &Quaternion<T>
Source§impl<T> Div<Quaternion<T>> for &UnitQuaternion<T>
impl<T> Div<Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Div<Quaternion<T>>>::Output
/
operator.Source§impl<T> Div<Quaternion<T>> for PureQuaternion<T>
impl<T> Div<Quaternion<T>> for PureQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
/
operator.Source§impl<T> Div<Quaternion<T>> for UnitQuaternion<T>
impl<T> Div<Quaternion<T>> for UnitQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
/
operator.Source§impl<T> Div<T> for &Quaternion<T>
impl<T> Div<T> for &Quaternion<T>
Source§impl<T> Div<T> for Quaternion<T>
impl<T> Div<T> for Quaternion<T>
Source§impl<T> Div<UnitQuaternion<T>> for &Quaternion<T>
impl<T> Div<UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Div<UnitQuaternion<T>>>::Output
/
operator.Source§impl<T> Div<UnitQuaternion<T>> for Quaternion<T>
impl<T> Div<UnitQuaternion<T>> for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
/
operator.Source§impl<T> Div for Quaternion<T>
impl<T> Div for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
/
operator.Source§fn div(self, rhs: Quaternion<T>) -> Self
fn div(self, rhs: Quaternion<T>) -> Self
/
operation. Read moreSource§impl<T, S> DivAssign<S> for Quaternion<T>
impl<T, S> DivAssign<S> for Quaternion<T>
Source§fn div_assign(&mut self, other: S)
fn div_assign(&mut self, other: S)
/=
operation. Read moreSource§impl<T> From<&T> for Quaternion<T>
impl<T> From<&T> for Quaternion<T>
Source§impl<'a, T> From<&'a UnitQuaternion<T>> for &'a Quaternion<T>
impl<'a, T> From<&'a UnitQuaternion<T>> for &'a Quaternion<T>
Source§fn from(q: &'a UnitQuaternion<T>) -> Self
fn from(q: &'a UnitQuaternion<T>) -> Self
Source§impl<T> From<T> for Quaternion<T>where
T: Zero,
impl<T> From<T> for Quaternion<T>where
T: Zero,
Source§impl<T> From<UnitQuaternion<T>> for Quaternion<T>
impl<T> From<UnitQuaternion<T>> for Quaternion<T>
Source§fn from(q: UnitQuaternion<T>) -> Self
fn from(q: UnitQuaternion<T>) -> Self
Source§impl<T: Hash> Hash for Quaternion<T>
impl<T: Hash> Hash for Quaternion<T>
Source§impl<T> Inv for &Quaternion<T>
impl<T> Inv for &Quaternion<T>
Source§impl<T> Inv for Quaternion<T>where
for<'a> &'a Self: Inv<Output = Quaternion<T>>,
impl<T> Inv for Quaternion<T>where
for<'a> &'a Self: Inv<Output = Quaternion<T>>,
Source§impl<T> Mul<&PureQuaternion<T>> for &Quaternion<T>
impl<T> Mul<&PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&PureQuaternion<T>> for Quaternion<T>
impl<T> Mul<&PureQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&Quaternion<T>> for &PureQuaternion<T>
impl<T> Mul<&Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&Quaternion<T>> for &Quaternion<T>
impl<T> Mul<&Quaternion<T>> for &Quaternion<T>
Source§impl<T> Mul<&Quaternion<T>> for &UnitQuaternion<T>
impl<T> Mul<&Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&Quaternion<T>> for PureQuaternion<T>
impl<T> Mul<&Quaternion<T>> for PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&Quaternion<T>> for Quaternion<T>
impl<T> Mul<&Quaternion<T>> for Quaternion<T>
Source§impl<T> Mul<&Quaternion<T>> for UnitQuaternion<T>
impl<T> Mul<&Quaternion<T>> for UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&T> for &Quaternion<T>
impl<T> Mul<&T> for &Quaternion<T>
Source§impl<T> Mul<&T> for Quaternion<T>
impl<T> Mul<&T> for Quaternion<T>
Source§impl<T> Mul<&UnitQuaternion<T>> for &Quaternion<T>
impl<T> Mul<&UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<&UnitQuaternion<T>> for Quaternion<T>
impl<T> Mul<&UnitQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<PureQuaternion<T>> for &Quaternion<T>
impl<T> Mul<PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<PureQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<PureQuaternion<T>> for Quaternion<T>
impl<T> Mul<PureQuaternion<T>> for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
*
operator.Source§impl<T> Mul<Quaternion<T>> for &PureQuaternion<T>
impl<T> Mul<Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<Quaternion<T>> for &Quaternion<T>
impl<T> Mul<Quaternion<T>> for &Quaternion<T>
Source§impl<T> Mul<Quaternion<T>> for &UnitQuaternion<T>
impl<T> Mul<Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Mul<Quaternion<T>>>::Output
*
operator.Source§impl<T> Mul<Quaternion<T>> for PureQuaternion<T>
impl<T> Mul<Quaternion<T>> for PureQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
*
operator.Source§impl<T> Mul<Quaternion<T>> for UnitQuaternion<T>
impl<T> Mul<Quaternion<T>> for UnitQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
*
operator.Source§impl<T> Mul<T> for &Quaternion<T>
impl<T> Mul<T> for &Quaternion<T>
Source§impl<T> Mul<T> for Quaternion<T>
impl<T> Mul<T> for Quaternion<T>
Source§impl<T> Mul<UnitQuaternion<T>> for &Quaternion<T>
impl<T> Mul<UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Mul<UnitQuaternion<T>>>::Output
*
operator.Source§impl<T> Mul<UnitQuaternion<T>> for Quaternion<T>
impl<T> Mul<UnitQuaternion<T>> for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
*
operator.Source§impl<T> Mul for Quaternion<T>
impl<T> Mul for Quaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
*
operator.Source§impl<T, S> MulAssign<S> for Quaternion<T>
impl<T, S> MulAssign<S> for Quaternion<T>
Source§fn mul_assign(&mut self, other: S)
fn mul_assign(&mut self, other: S)
*=
operation. Read moreSource§impl<T> Neg for Quaternion<T>where
T: Neg<Output = T>,
impl<T> Neg for Quaternion<T>where
T: Neg<Output = T>,
Source§impl<T> One for Quaternion<T>
impl<T> One for Quaternion<T>
Source§impl<T: PartialEq> PartialEq for Quaternion<T>
impl<T: PartialEq> PartialEq for Quaternion<T>
Source§impl<T> Serialize for Quaternion<T>where
T: Serialize,
impl<T> Serialize for Quaternion<T>where
T: Serialize,
Source§impl<T> Sub<&PureQuaternion<T>> for &Quaternion<T>
impl<T> Sub<&PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&PureQuaternion<T>> for Quaternion<T>
impl<T> Sub<&PureQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&Quaternion<T>> for &PureQuaternion<T>
impl<T> Sub<&Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&Quaternion<T>> for &Quaternion<T>
impl<T> Sub<&Quaternion<T>> for &Quaternion<T>
Source§impl<T> Sub<&Quaternion<T>> for &UnitQuaternion<T>
impl<T> Sub<&Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&Quaternion<T>> for PureQuaternion<T>
impl<T> Sub<&Quaternion<T>> for PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&Quaternion<T>> for Quaternion<T>
impl<T> Sub<&Quaternion<T>> for Quaternion<T>
Source§impl<T> Sub<&Quaternion<T>> for UnitQuaternion<T>
impl<T> Sub<&Quaternion<T>> for UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&T> for &Quaternion<T>
impl<T> Sub<&T> for &Quaternion<T>
Source§impl<T> Sub<&T> for Quaternion<T>
impl<T> Sub<&T> for Quaternion<T>
Source§impl<T> Sub<&UnitQuaternion<T>> for &Quaternion<T>
impl<T> Sub<&UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<&UnitQuaternion<T>> for Quaternion<T>
impl<T> Sub<&UnitQuaternion<T>> for Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<PureQuaternion<T>> for &Quaternion<T>
impl<T> Sub<PureQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<PureQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<PureQuaternion<T>> for Quaternion<T>where
T: Sub<T, Output = T>,
impl<T> Sub<PureQuaternion<T>> for Quaternion<T>where
T: Sub<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
-
operator.Source§impl<T> Sub<Quaternion<T>> for &PureQuaternion<T>
impl<T> Sub<Quaternion<T>> for &PureQuaternion<T>
Source§type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <PureQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<Quaternion<T>> for &Quaternion<T>
impl<T> Sub<Quaternion<T>> for &Quaternion<T>
Source§impl<T> Sub<Quaternion<T>> for &UnitQuaternion<T>
impl<T> Sub<Quaternion<T>> for &UnitQuaternion<T>
Source§type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
type Output = <UnitQuaternion<T> as Sub<Quaternion<T>>>::Output
-
operator.Source§impl<T> Sub<Quaternion<T>> for PureQuaternion<T>
impl<T> Sub<Quaternion<T>> for PureQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
-
operator.Source§impl<T> Sub<Quaternion<T>> for UnitQuaternion<T>
impl<T> Sub<Quaternion<T>> for UnitQuaternion<T>
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
-
operator.Source§impl<T> Sub<T> for &Quaternion<T>
impl<T> Sub<T> for &Quaternion<T>
Source§impl<T> Sub<T> for Quaternion<T>where
T: Sub<T, Output = T>,
impl<T> Sub<T> for Quaternion<T>where
T: Sub<T, Output = T>,
Source§impl<T> Sub<UnitQuaternion<T>> for &Quaternion<T>
impl<T> Sub<UnitQuaternion<T>> for &Quaternion<T>
Source§type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
type Output = <Quaternion<T> as Sub<UnitQuaternion<T>>>::Output
-
operator.Source§impl<T> Sub<UnitQuaternion<T>> for Quaternion<T>where
T: Sub<T, Output = T>,
impl<T> Sub<UnitQuaternion<T>> for Quaternion<T>where
T: Sub<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
-
operator.Source§fn sub(self, rhs: UnitQuaternion<T>) -> Self
fn sub(self, rhs: UnitQuaternion<T>) -> Self
-
operation. Read moreSource§impl<T> Sub for Quaternion<T>where
T: Sub<T, Output = T>,
impl<T> Sub for Quaternion<T>where
T: Sub<T, Output = T>,
Source§type Output = Quaternion<T>
type Output = Quaternion<T>
-
operator.Source§impl<T, S> SubAssign<S> for Quaternion<T>
impl<T, S> SubAssign<S> for Quaternion<T>
Source§fn sub_assign(&mut self, other: S)
fn sub_assign(&mut self, other: S)
-=
operation. Read more