Struct ultraviolet::mat::Mat2

source ·
#[repr(C)]
pub struct Mat2 { pub cols: [Vec2; 2], }
Expand description

A 2x2 square matrix.

Useful for performing linear transformations (rotation, scaling) on 2d vectors.

Fields§

§cols: [Vec2; 2]

Implementations§

source§

impl Mat2

source

pub const fn new(col1: Vec2, col2: Vec2) -> Self

source

pub fn identity() -> Self

source

pub fn into_homogeneous(self) -> Mat3

Turn this into a homogeneous 2d transformation matrix.

source

pub fn transpose(&mut self)

source

pub fn transposed(&self) -> Self

source

pub fn determinant(&self) -> f32

source

pub fn adjugate(&self) -> Self

The adjugate of this matrix, i.e. the transpose of the cofactor matrix.

This is equivalent to the inverse but without dividing by the determinant of the matrix, which can be useful in some contexts for better performance.

One such case is when this matrix is interpreted as a a homogeneous transformation matrix, in which case uniform scaling will not affect the resulting projected 3d version of transformed points or vectors.

source

pub fn inverse(&mut self)

If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.

source

pub fn inversed(&self) -> Self

If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.

source

pub fn layout() -> Layout

Get the core::alloc::Layout of Self

source

pub fn as_array(&self) -> &[f32; 4]

Interpret self as a statically-sized array of its base numeric type

source

pub fn as_mut_array(&mut self) -> &mut [f32; 4]

Interpret self as a statically-sized array of its base numeric type

source

pub fn as_component_array(&self) -> &[Vec2; 2]

Interpret self as a statically-sized array of its component (column) vector type

source

pub fn as_mut_component_array(&mut self) -> &mut [Vec2; 2]

Interpret self as a statically-sized array of its component (column) vector type

source

pub fn as_slice(&self) -> &[f32]

Interpret self as a slice of its base numeric type

source

pub fn as_mut_slice(&mut self) -> &mut [f32]

Interpret self as a slice of its base numeric type

source

pub fn as_component_slice(&self) -> &[Vec2]

Interpret self as a slice of its component (column) vector type

source

pub fn as_mut_component_slice(&mut self) -> &mut [Vec2]

Interpret self as a slice of its component (column) vector type

source

pub fn as_byte_slice(&self) -> &[u8]

Interpret self as a slice of bytes

source

pub fn as_mut_byte_slice(&mut self) -> &mut [u8]

Interpret self as a slice of bytes

source

pub const fn as_ptr(&self) -> *const f32

Returns a constant unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

Safety

It is up to the caller to correctly use this pointer and its bounds.

source

pub fn as_mut_ptr(&mut self) -> *mut f32

Returns a mutable unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

Safety

It is up to the caller to correctly use this pointer and its bounds.

Trait Implementations§

source§

impl Add<Mat2> for Mat2

§

type Output = Mat2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Mat2) -> Self

Performs the + operation. Read more
source§

impl AddAssign<Mat2> for Mat2

source§

fn add_assign(&mut self, rhs: Mat2)

Performs the += operation. Read more
source§

impl Clone for Mat2

source§

fn clone(&self) -> Mat2

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mat2

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Mat2

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Mat2

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&[f32; 4]> for Mat2

source§

fn from(comps: &[f32; 4]) -> Self

Converts to this type from the input type.
source§

impl From<[[f32; 2]; 2]> for Mat2

source§

fn from(comps: [[f32; 2]; 2]) -> Self

Converts to this type from the input type.
source§

impl From<[f32; 4]> for Mat2

source§

fn from(comps: [f32; 4]) -> Self

Converts to this type from the input type.
source§

impl From<ColumnMatrix2<f32>> for Mat2

source§

fn from(v: ColumnMatrix2<f32>) -> Self

Converts to this type from the input type.
source§

impl From<Mat2> for [[f32; 2]; 2]

source§

fn from(mat2: Mat2) -> Self

Converts to this type from the input type.
source§

impl From<Mat2> for ColumnMatrix2<f32>

source§

fn from(v: Mat2) -> Self

Converts to this type from the input type.
source§

impl From<Rotor2> for Mat2

source§

fn from(rotor: Rotor2) -> Mat2

Converts to this type from the input type.
source§

impl Index<usize> for Mat2

§

type Output = Vec2

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Mat2

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl Mul<Mat2> for Mat2

§

type Output = Mat2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl Mul<Mat2> for f32

§

type Output = Mat2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Mat2) -> Mat2

Performs the * operation. Read more
source§

impl Mul<Vec2> for Mat2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec2) -> Vec2

Performs the * operation. Read more
source§

impl Mul<f32> for Mat2

§

type Output = Mat2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Mat2

Performs the * operation. Read more
source§

impl PartialEq<Mat2> for Mat2

source§

fn eq(&self, other: &Mat2) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Mat2

source§

fn serialize<T>(&self, serializer: T) -> Result<T::Ok, T::Error>where T: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Zeroable for Mat2

source§

fn zeroed() -> Self

source§

impl Copy for Mat2

source§

impl Pod for Mat2

source§

impl StructuralPartialEq for Mat2

Auto Trait Implementations§

§

impl RefUnwindSafe for Mat2

§

impl Send for Mat2

§

impl Sync for Mat2

§

impl Unpin for Mat2

§

impl UnwindSafe for Mat2

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> AnyBitPattern for Twhere T: Pod,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> NoUninit for Twhere T: Pod,