DMat2

Struct DMat2 

Source
#[repr(C)]
pub struct DMat2 { pub x_axis: DVec2, pub y_axis: DVec2, }
Expand description

A 2x2 column major matrix.

Fieldsยง

ยงx_axis: DVec2ยงy_axis: DVec2

Implementationsยง

Sourceยง

impl DMat2

Source

pub const ZERO: DMat2

A 2x2 matrix with all elements set to 0.0.

Source

pub const IDENTITY: DMat2

A 2x2 identity matrix, where all diagonal elements are 1, and all off-diagonal elements are 0.

Source

pub const NAN: DMat2

All NAN:s.

Source

pub const fn from_cols(x_axis: DVec2, y_axis: DVec2) -> DMat2

Creates a 2x2 matrix from two column vectors.

Source

pub const fn from_cols_array(m: &[f64; 4]) -> DMat2

Creates a 2x2 matrix from a [f64; 4] array stored in column major order. If your data is stored in row major you will need to transpose the returned matrix.

Source

pub const fn to_cols_array(&self) -> [f64; 4]

Creates a [f64; 4] array storing data in column major order. If you require data in row major order transpose the matrix first.

Source

pub const fn from_cols_array_2d(m: &[[f64; 2]; 2]) -> DMat2

Creates a 2x2 matrix from a [[f64; 2]; 2] 2D array stored in column major order. If your data is in row major order you will need to transpose the returned matrix.

Source

pub const fn to_cols_array_2d(&self) -> [[f64; 2]; 2]

Creates a [[f64; 2]; 2] 2D array storing data in column major order. If you require data in row major order transpose the matrix first.

Source

pub const fn from_diagonal(diagonal: DVec2) -> DMat2

Creates a 2x2 matrix with its diagonal set to diagonal and all other entries set to 0.

Source

pub fn from_scale_angle(scale: DVec2, angle: f64) -> DMat2

Creates a 2x2 matrix containing the combining non-uniform scale and rotation of angle (in radians).

Source

pub fn from_angle(angle: f64) -> DMat2

Creates a 2x2 matrix containing a rotation of angle (in radians).

Source

pub fn from_mat3(m: DMat3) -> DMat2

Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.

Source

pub const fn from_cols_slice(slice: &[f64]) -> DMat2

Creates a 2x2 matrix from the first 4 values in slice.

ยงPanics

Panics if slice is less than 4 elements long.

Source

pub fn write_cols_to_slice(self, slice: &mut [f64])

Writes the columns of self to the first 4 elements in slice.

ยงPanics

Panics if slice is less than 4 elements long.

Source

pub fn col(&self, index: usize) -> DVec2

Returns the matrix column for the given index.

ยงPanics

Panics if index is greater than 1.

Source

pub fn col_mut(&mut self, index: usize) -> &mut DVec2

Returns a mutable reference to the matrix column for the given index.

ยงPanics

Panics if index is greater than 1.

Source

pub fn row(&self, index: usize) -> DVec2

Returns the matrix row for the given index.

ยงPanics

Panics if index is greater than 1.

Source

pub fn is_finite(&self) -> bool

Returns true if, and only if, all elements are finite. If any element is either NaN, positive or negative infinity, this will return false.

Source

pub fn is_nan(&self) -> bool

Returns true if any elements are NaN.

Source

pub fn transpose(&self) -> DMat2

Returns the transpose of self.

Source

pub fn determinant(&self) -> f64

Returns the determinant of self.

Source

pub fn inverse(&self) -> DMat2

Returns the inverse of self.

If the matrix is not invertible the returned matrix will be invalid.

ยงPanics

Will panic if the determinant of self is zero when glam_assert is enabled.

Source

pub fn mul_vec2(&self, rhs: DVec2) -> DVec2

Transforms a 2D vector.

Source

pub fn mul_mat2(&self, rhs: &DMat2) -> DMat2

Multiplies two 2x2 matrices.

Source

pub fn add_mat2(&self, rhs: &DMat2) -> DMat2

Adds two 2x2 matrices.

Source

pub fn sub_mat2(&self, rhs: &DMat2) -> DMat2

Subtracts two 2x2 matrices.

Source

pub fn mul_scalar(&self, rhs: f64) -> DMat2

Multiplies a 2x2 matrix by a scalar.

Source

pub fn abs_diff_eq(&self, rhs: DMat2, max_abs_diff: f64) -> bool

Returns true if the absolute difference of all elements between self and rhs is less than or equal to max_abs_diff.

This can be used to compare if two matrices contain similar elements. It works best when comparing with a known value. The max_abs_diff that should be used used depends on the values being compared against.

For more see comparing floating point numbers.

Source

pub fn as_mat2(&self) -> Mat2

Trait Implementationsยง

Sourceยง

impl Add for DMat2

Sourceยง

type Output = DMat2

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: DMat2) -> <DMat2 as Add>::Output

Performs the + operation. Read more
Sourceยง

impl AddAssign for DMat2

Sourceยง

fn add_assign(&mut self, rhs: DMat2)

Performs the += operation. Read more
Sourceยง

impl AsMut<[f64; 4]> for DMat2

Available on non-target_arch=spirv only.
Sourceยง

fn as_mut(&mut self) -> &mut [f64; 4]

Converts this type into a mutable reference of the (usually inferred) input type.
Sourceยง

impl AsRef<[f64; 4]> for DMat2

Available on non-target_arch=spirv only.
Sourceยง

fn as_ref(&self) -> &[f64; 4]

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl Clone for DMat2

Sourceยง

fn clone(&self) -> DMat2

Returns a duplicate of the value. Read more
1.0.0ยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for DMat2

Available on non-target_arch=spirv only.
Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for DMat2

Sourceยง

fn default() -> DMat2

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Display for DMat2

Available on non-target_arch=spirv only.
Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Mul<DVec2> for DMat2

Sourceยง

type Output = DVec2

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: DVec2) -> <DMat2 as Mul<DVec2>>::Output

Performs the * operation. Read more
Sourceยง

impl Mul<f64> for DMat2

Sourceยง

type Output = DMat2

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: f64) -> <DMat2 as Mul<f64>>::Output

Performs the * operation. Read more
Sourceยง

impl Mul for DMat2

Sourceยง

type Output = DMat2

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: DMat2) -> <DMat2 as Mul>::Output

Performs the * operation. Read more
Sourceยง

impl MulAssign<f64> for DMat2

Sourceยง

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Sourceยง

impl MulAssign for DMat2

Sourceยง

fn mul_assign(&mut self, rhs: DMat2)

Performs the *= operation. Read more
Sourceยง

impl Neg for DMat2

Sourceยง

type Output = DMat2

The resulting type after applying the - operator.
Sourceยง

fn neg(self) -> <DMat2 as Neg>::Output

Performs the unary - operation. Read more
Sourceยง

impl PartialEq for DMat2

Sourceยง

fn eq(&self, rhs: &DMat2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0ยง

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl<'a> Product<&'a DMat2> for DMat2

Sourceยง

fn product<I>(iter: I) -> DMat2
where I: Iterator<Item = &'a DMat2>,

Takes an iterator and generates Self from the elements by multiplying the items.
Sourceยง

impl Product for DMat2

Sourceยง

fn product<I>(iter: I) -> DMat2
where I: Iterator<Item = DMat2>,

Takes an iterator and generates Self from the elements by multiplying the items.
Sourceยง

impl Sub for DMat2

Sourceยง

type Output = DMat2

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: DMat2) -> <DMat2 as Sub>::Output

Performs the - operation. Read more
Sourceยง

impl SubAssign for DMat2

Sourceยง

fn sub_assign(&mut self, rhs: DMat2)

Performs the -= operation. Read more
Sourceยง

impl<'a> Sum<&'a DMat2> for DMat2

Sourceยง

fn sum<I>(iter: I) -> DMat2
where I: Iterator<Item = &'a DMat2>,

Takes an iterator and generates Self from the elements by โ€œsumming upโ€ the items.
Sourceยง

impl Sum for DMat2

Sourceยง

fn sum<I>(iter: I) -> DMat2
where I: Iterator<Item = DMat2>,

Takes an iterator and generates Self from the elements by โ€œsumming upโ€ the items.
Sourceยง

impl Copy for DMat2

Auto Trait Implementationsยง

Blanket Implementationsยง

ยง

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

ยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
ยง

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

ยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
ยง

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

ยง

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

Mutably borrows from an owned value. Read more
ยง

impl<T> CloneToUninit for T
where T: Clone,

ยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> Downcast<T> for T

Sourceยง

impl<T> Downcast for T
where T: Any,

Sourceยง

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>

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)

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)

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
where T: Any + Send + Sync,

Sourceยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
ยง

impl<T> From<T> for T

ยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
ยง

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

ยง

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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Sourceยง

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Sourceยง

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Sourceยง

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Sourceยง

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
ยง

impl<T> ToOwned for T
where T: Clone,

ยง

type Owned = T

The resulting type after obtaining ownership.
ยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
ยง

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

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T> ToSmolStr for T
where T: Display + ?Sized,

ยง

impl<T> ToString for T
where T: Display + ?Sized,

ยง

fn to_string(&self) -> String

Converts the given value to a String. Read more
ยง

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

ยง

type Error = Infallible

The type returned in the event of a conversion error.
ยง

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

Performs the conversion.
ยง

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

ยง

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

The type returned in the event of a conversion error.
ยง

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

Performs the conversion.
Sourceยง

impl<T> Upcast<T> for T

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

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
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

impl<T> WasmNotSend for T
where T: Send,

Sourceยง

impl<T> WasmNotSendSync for T

Sourceยง

impl<T> WasmNotSync for T
where T: Sync,