#[repr(C)]pub struct Matrix2<S> {
pub x: Vector2<S>,
pub y: Vector2<S>,
}Expand description
A 2 x 2, column major matrix
This type is marked as #[repr(C)].
Fields§
§x: Vector2<S>The first column of the matrix.
y: Vector2<S>The second column of the matrix.
Implementations§
Source§impl<S> Matrix2<S>where
S: BaseFloat,
impl<S> Matrix2<S>where
S: BaseFloat,
Sourcepub fn look_at(dir: Vector2<S>, up: Vector2<S>) -> Matrix2<S>
pub fn look_at(dir: Vector2<S>, up: Vector2<S>) -> Matrix2<S>
Create a transformation matrix that will cause unit_x() to point at
dir. unit_y() will be perpendicular to dir, and the closest to up.
Sourcepub fn look_at_stable(dir: Vector2<S>, flip: bool) -> Matrix2<S>
pub fn look_at_stable(dir: Vector2<S>, flip: bool) -> Matrix2<S>
Crate a transformation that will cause unit_x() to point at
dir. This is similar to look_at, but does not take an up vector.
This will not cause unit_y() to flip when dir crosses over the up vector.
pub fn from_angle<A>(theta: A) -> Matrix2<S>
Trait Implementations§
Source§impl<S> AbsDiffEq for Matrix2<S>where
S: BaseFloat,
impl<S> AbsDiffEq for Matrix2<S>where
S: BaseFloat,
Source§fn default_epsilon() -> <S as AbsDiffEq>::Epsilon
fn default_epsilon() -> <S as AbsDiffEq>::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Matrix2<S>, epsilon: <S as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.Source§impl<S> AddAssign for Matrix2<S>
impl<S> AddAssign for Matrix2<S>
Source§fn add_assign(&mut self, other: Matrix2<S>)
fn add_assign(&mut self, other: Matrix2<S>)
Performs the
+= operation. Read moreSource§impl<S> DivAssign<S> for Matrix2<S>
impl<S> DivAssign<S> for Matrix2<S>
Source§fn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the
/= operation. Read moreSource§impl<S> Matrix for Matrix2<S>where
S: BaseFloat,
impl<S> Matrix for Matrix2<S>where
S: BaseFloat,
Source§impl<S> MulAssign<S> for Matrix2<S>
impl<S> MulAssign<S> for Matrix2<S>
Source§fn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the
*= operation. Read moreSource§impl<S> RelativeEq for Matrix2<S>where
S: BaseFloat,
impl<S> RelativeEq for Matrix2<S>where
S: BaseFloat,
Source§fn default_max_relative() -> <S as AbsDiffEq>::Epsilon
fn default_max_relative() -> <S as AbsDiffEq>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq>::Epsilon,
max_relative: <S as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Matrix2<S>, epsilon: <S as AbsDiffEq>::Epsilon, max_relative: <S as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
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
The inverse of
RelativeEq::relative_eq.Source§impl<S> RemAssign<S> for Matrix2<S>
impl<S> RemAssign<S> for Matrix2<S>
Source§fn rem_assign(&mut self, scalar: S)
fn rem_assign(&mut self, scalar: S)
Performs the
%= operation. Read moreSource§impl<S> SquareMatrix for Matrix2<S>where
S: BaseFloat,
impl<S> SquareMatrix for Matrix2<S>where
S: BaseFloat,
Source§fn from_value(value: S) -> Matrix2<S>
fn from_value(value: S) -> Matrix2<S>
Create a new diagonal matrix using the supplied value.
Source§fn from_diagonal(value: Vector2<S>) -> Matrix2<S>
fn from_diagonal(value: Vector2<S>) -> Matrix2<S>
Create a matrix from a non-uniform scale
Source§fn transpose_self(&mut self)
fn transpose_self(&mut self)
Transpose this matrix in-place.
Source§fn determinant(&self) -> S
fn determinant(&self) -> S
Take the determinant of this matrix.
Source§fn invert(&self) -> Option<Matrix2<S>>
fn invert(&self) -> Option<Matrix2<S>>
Invert this matrix, returning a new matrix.
m.mul_m(m.invert()) is
the identity matrix. Returns None if this matrix is not invertible
(has a determinant of zero).Source§fn is_diagonal(&self) -> bool
fn is_diagonal(&self) -> bool
Test if this is a diagonal matrix. That is, every element outside of
the diagonal is 0.
Source§fn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
Test if this matrix is symmetric. That is, it is equal to its
transpose.
Source§fn identity() -> Self
fn identity() -> Self
The identity matrix. Multiplying this matrix with another should have
no effect. Read more
Source§fn trace(&self) -> Self::Scalar
fn trace(&self) -> Self::Scalar
Return the trace of this matrix. That is, the sum of the diagonal.
Source§fn is_identity(&self) -> boolwhere
Self: UlpsEq,
fn is_identity(&self) -> boolwhere
Self: UlpsEq,
Test if this matrix is the identity matrix. That is, it is diagonal
and every element in the diagonal is one.
Source§impl<S> SubAssign for Matrix2<S>
impl<S> SubAssign for Matrix2<S>
Source§fn sub_assign(&mut self, other: Matrix2<S>)
fn sub_assign(&mut self, other: Matrix2<S>)
Performs the
-= operation. Read moreSource§impl<S> UlpsEq for Matrix2<S>where
S: BaseFloat,
impl<S> UlpsEq for Matrix2<S>where
S: BaseFloat,
Source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
Source§impl<S> VectorSpace for Matrix2<S>where
S: BaseFloat,
impl<S> VectorSpace for Matrix2<S>where
S: BaseFloat,
impl<S> Copy for Matrix2<S>where
S: Copy,
impl<S> StructuralPartialEq for Matrix2<S>
Auto Trait Implementations§
impl<S> Freeze for Matrix2<S>where
S: Freeze,
impl<S> RefUnwindSafe for Matrix2<S>where
S: RefUnwindSafe,
impl<S> Send for Matrix2<S>where
S: Send,
impl<S> Sync for Matrix2<S>where
S: Sync,
impl<S> Unpin for Matrix2<S>where
S: Unpin,
impl<S> UnwindSafe for Matrix2<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.