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
sourceimpl<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> where
A: Into<Rad<S>>,
Trait Implementations
sourceimpl<S> AbsDiffEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
impl<S> AbsDiffEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
fn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
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].
sourceimpl<S> AddAssign<Matrix2<S>> for Matrix2<S> where
S: BaseFloat + AddAssign<S>,
impl<S> AddAssign<Matrix2<S>> for Matrix2<S> where
S: BaseFloat + AddAssign<S>,
sourcefn add_assign(&mut self, other: Matrix2<S>)
fn add_assign(&mut self, other: Matrix2<S>)
Performs the += operation. Read more
sourceimpl<S> DivAssign<S> for Matrix2<S> where
S: BaseFloat + DivAssign<S>,
impl<S> DivAssign<S> for Matrix2<S> where
S: BaseFloat + DivAssign<S>,
sourcefn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the /= operation. Read more
sourceimpl<S> Matrix for Matrix2<S> where
S: BaseFloat,
impl<S> Matrix for Matrix2<S> where
S: BaseFloat,
sourcefn swap_columns(&mut self, a: usize, b: usize)
fn swap_columns(&mut self, a: usize, b: usize)
Swap two columns of this array.
sourcefn swap_elements(&mut self, a: (usize, usize), b: (usize, usize))
fn swap_elements(&mut self, a: (usize, usize), b: (usize, usize))
Swap the values at index a and b
sourcefn as_mut_ptr(&mut self) -> *mut Self::Scalar
fn as_mut_ptr(&mut self) -> *mut Self::Scalar
Get a mutable pointer to the first element of the array.
sourcefn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column
fn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column
Replace a column in the array.
sourceimpl<S> MulAssign<S> for Matrix2<S> where
S: BaseFloat + MulAssign<S>,
impl<S> MulAssign<S> for Matrix2<S> where
S: BaseFloat + MulAssign<S>,
sourcefn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the *= operation. Read more
sourceimpl<S> RelativeEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
impl<S> RelativeEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
sourcefn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
fn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Matrix2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
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].
sourceimpl<S> RemAssign<S> for Matrix2<S> where
S: BaseFloat + RemAssign<S>,
impl<S> RemAssign<S> for Matrix2<S> where
S: BaseFloat + RemAssign<S>,
sourcefn rem_assign(&mut self, scalar: S)
fn rem_assign(&mut self, scalar: S)
Performs the %= operation. Read more
sourceimpl<S> SquareMatrix for Matrix2<S> where
S: BaseFloat,
impl<S> SquareMatrix for Matrix2<S> where
S: BaseFloat,
sourcefn from_value(value: S) -> Matrix2<S>
fn from_value(value: S) -> Matrix2<S>
Create a new diagonal matrix using the supplied value.
sourcefn from_diagonal(value: Vector2<S>) -> Matrix2<S>
fn from_diagonal(value: Vector2<S>) -> Matrix2<S>
Create a matrix from a non-uniform scale
sourcefn transpose_self(&mut self)
fn transpose_self(&mut self)
Transpose this matrix in-place.
sourcefn determinant(&self) -> S
fn determinant(&self) -> S
Take the determinant of this matrix.
sourcefn 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). Read more
sourcefn 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. Read more
sourcefn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
Test if this matrix is symmetric. That is, it is equal to its transpose. Read more
sourcefn identity() -> Self
fn identity() -> Self
The identity matrix. Multiplying this matrix with another should have no effect. Read more
sourcefn trace(&self) -> Self::Scalar
fn trace(&self) -> Self::Scalar
Return the trace of this matrix. That is, the sum of the diagonal.
sourcefn is_invertible(&self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
fn is_invertible(&self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
Test if this matrix is invertible.
sourcefn is_identity(&self) -> bool where
Self: UlpsEq<Self>,
fn is_identity(&self) -> bool where
Self: UlpsEq<Self>,
Test if this matrix is the identity matrix. That is, it is diagonal and every element in the diagonal is one. Read more
sourceimpl<S> SubAssign<Matrix2<S>> for Matrix2<S> where
S: BaseFloat + SubAssign<S>,
impl<S> SubAssign<Matrix2<S>> for Matrix2<S> where
S: BaseFloat + SubAssign<S>,
sourcefn sub_assign(&mut self, other: Matrix2<S>)
fn sub_assign(&mut self, other: Matrix2<S>)
Performs the -= operation. Read more
sourceimpl<S> UlpsEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
impl<S> UlpsEq<Matrix2<S>> for Matrix2<S> where
S: BaseFloat,
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
sourceimpl<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>
impl<T: UniformDataType + PrimitiveDataType> UniformDataType for Matrix2<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more