pub struct Quat<E>(pub Vector<E, 4>)
where
E: MatEl;Expand description
Represents a quaternion using a 4D vector for its components [x, y, z, w].
The w component is the scalar part, and (x, y, z) is the vector part.
Tuple Fields§
§0: Vector<E, 4>Implementations§
Source§impl<E> Quat<E>
impl<E> Quat<E>
Sourcepub fn from_axis_angle<T>(axis: T, angle: E) -> Selfwhere
T: VectorIter<E, 3>,
pub fn from_axis_angle<T>(axis: T, angle: E) -> Selfwhere
T: VectorIter<E, 3>,
Creates a quaternion from a normalized axis and an angle in radians.
§Arguments
axis- The normalized 3D vector representing the axis of rotation.angle- The angle of rotation in radians.
Sourcepub fn to_array(&self) -> [E; 4]
pub fn to_array(&self) -> [E; 4]
Converts the quaternion’s components into a 4-element array [x, y, z, w].
Sourcepub fn conjugate(self) -> Self
pub fn conjugate(self) -> Self
Computes the conjugate of the quaternion, inverting its vector part.
Sourcepub fn multiply(&self, other: &Self) -> Self
pub fn multiply(&self, other: &Self) -> Self
Multiplies this quaternion by another quaternion (self * other).
Sourcepub fn multiply_mut(&mut self, other: &Self)
pub fn multiply_mut(&mut self, other: &Self)
Multiplies this quaternion by another in-place.
Sourcepub fn premultiply(&self, other: &Self) -> Self
pub fn premultiply(&self, other: &Self) -> Self
Multiplies another quaternion by this one (other * self).
Sourcepub fn premultiply_mut(&mut self, other: &Self)
pub fn premultiply_mut(&mut self, other: &Self)
Multiplies another quaternion by this one in-place.
Sourcepub fn devide(&self, other: &Self) -> Self
pub fn devide(&self, other: &Self) -> Self
Divides this quaternion by another (equivalent to self * other.invert()).
Sourcepub fn device_mut(&mut self, other: &Self)
pub fn device_mut(&mut self, other: &Self)
Divides this quaternion by another in-place.
Sourcepub fn slerp(self, other: &Self, s: E) -> Self
pub fn slerp(self, other: &Self, s: E) -> Self
Performs spherical linear interpolation (slerp) between two unit quaternions.
§Arguments
other- The target quaternion to interpolate towards.s- The interpolation factor, a value between 0.0 and 1.0.
Sourcepub fn slerp_mut(&mut self, other: &Self, s: E)
pub fn slerp_mut(&mut self, other: &Self, s: E)
Performs spherical linear interpolation (slerp) in-place.
Sourcepub fn invert(&self) -> Self
pub fn invert(&self) -> Self
Inverts the unit-length quaternion, which is equivalent to its conjugate.
Sourcepub fn to_matrix(&self) -> Mat3<E, DescriptorOrderColumnMajor>
pub fn to_matrix(&self) -> Mat3<E, DescriptorOrderColumnMajor>
Converts the quaternion into a column-major 3x3 rotation matrix.
Sourcepub fn from_angle_x(x: E) -> Self
pub fn from_angle_x(x: E) -> Self
Creates a quaternion representing a rotation around the X-axis.
§Arguments
x- The rotation angle in radians.
Sourcepub fn from_angle_y(y: E) -> Self
pub fn from_angle_y(y: E) -> Self
Creates a quaternion representing a rotation around the Y-axis.
§Arguments
y- The rotation angle in radians.
Sourcepub fn from_angle_z(z: E) -> Self
pub fn from_angle_z(z: E) -> Self
Creates a quaternion representing a rotation around the Z-axis.
§Arguments
z- The rotation angle in radians.
Sourcepub fn from_euler_xyz<T: VectorIter<E, 3>>(angles: T) -> Self
pub fn from_euler_xyz<T: VectorIter<E, 3>>(angles: T) -> Self
Creates a quaternion from Euler angles in XYZ order.
§Arguments
angles- A 3D vector containing the rotation angles (in radians) for the X, Y, and Z axes.
Trait Implementations§
Source§impl<E> AbsDiffEq for Quat<E>
impl<E> AbsDiffEq for Quat<E>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.Source§impl<E> AddAssign<E> for Quat<E>
impl<E> AddAssign<E> for Quat<E>
Source§fn add_assign(&mut self, rhs: E)
fn add_assign(&mut self, rhs: E)
+= operation. Read moreSource§impl<E> AddAssign for Quat<E>
impl<E> AddAssign for Quat<E>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<E> DivAssign<E> for Quat<E>
impl<E> DivAssign<E> for Quat<E>
Source§fn div_assign(&mut self, rhs: E)
fn div_assign(&mut self, rhs: E)
/= operation. Read moreSource§impl<E> DivAssign for Quat<E>
impl<E> DivAssign for Quat<E>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl<E: MatEl> From<(E, E, E, E)> for Quat<E>
impl<E: MatEl> From<(E, E, E, E)> for Quat<E>
Source§fn from(value: (E, E, E, E)) -> Self
fn from(value: (E, E, E, E)) -> Self
Source§impl<E> MulAssign<E> for Quat<E>
impl<E> MulAssign<E> for Quat<E>
Source§fn mul_assign(&mut self, rhs: E)
fn mul_assign(&mut self, rhs: E)
*= operation. Read moreSource§impl<E> MulAssign for Quat<E>
impl<E> MulAssign for Quat<E>
Source§fn mul_assign(&mut self, rhs: Quat<E>)
fn mul_assign(&mut self, rhs: Quat<E>)
*= operation. Read moreSource§impl<E> PartialOrd for Quat<E>where
E: MatEl + PartialOrd,
impl<E> PartialOrd for Quat<E>where
E: MatEl + PartialOrd,
Source§impl<E> RelativeEq for Quat<E>
impl<E> RelativeEq for Quat<E>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq.Source§impl<E> SubAssign for Quat<E>
impl<E> SubAssign for Quat<E>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more