Struct geng::prelude::mat3

#[repr(C)]
pub struct mat3<T>(/* private fields */);
Expand description

3x3 matrix

Implementations§

§

impl<T> mat3<T>
where T: Copy,

pub fn transpose(self) -> mat3<T>

Get transposed matrix.

§Examples
let matrix = mat3::translate(vec2(1, 2));
let matrix_transposed = matrix.transpose();
for i in 0..3 {
    for j in 0..3 {
        assert_eq!(matrix[(i, j)], matrix_transposed[(j, i)]);
    }
}
§

impl<T> mat3<T>
where T: Num,

pub fn from_orts(x: vec2<T>, y: vec2<T>) -> mat3<T>

Construct a transformation matrix with given orts

§Examples
let e1 = vec2(1.0, 2.0);
let e2 = vec2(3.0, 4.0);
let m = mat3::from_orts(e1, e2);
assert_eq!(vec2(1.0, 0.0).transform(m), e1);
assert_eq!(vec2(0.0, 1.0).transform(m), e2);
let v = vec2(2.0, 3.0);
assert_eq!(v.transform(m), e1 * v.x + e2 * v.y);

pub fn extend3d(self) -> mat4<T>

Extend this into a 3d transformation matrix, leaving z coordinate as is

§

impl<T> mat3<T>
where T: Float,

pub fn inverse(self) -> mat3<T>

Get inverse matrix.

§Examples
let matrix = mat3::<f64>::rotate(Angle::from_radians(0.123));
let matrix_inv = matrix.inverse();
let mult = matrix * matrix_inv;
for i in 0..3 {
    for j in 0..3 {
        assert!((mult[(i, j)] - if i == j { 1.0 } else { 0.0 }).abs() < 1e-5);
    }
}
§

impl<T> mat3<T>
where T: Float,

pub fn ortho(aabb: Aabb2<T>) -> mat3<T>

Get 2d part of the orthographic projection matrix

§

impl<T> mat3<T>
where T: Num + Copy,

pub fn scale_uniform(factor: T) -> mat3<T>

Construct a uniform scale matrix.

§Examples
let matrix = mat3::scale_uniform(2);
assert_eq!(matrix * vec3(1, 2, 1), vec3(2, 4, 1));

pub fn scale_uniform_around(p: vec2<T>, scale: T) -> mat3<T>

Construct matrix that performs uniform scaling around a specified point

pub fn scale_around(p: vec2<T>, scale: vec2<T>) -> mat3<T>

Construct matrix that performs scaling around a specified point

pub fn scale(factor: vec2<T>) -> mat3<T>

Construct a scale matrix.

§Examples
let matrix = mat3::scale(vec2(1, 2));
assert_eq!(matrix * vec3(1, 2, 1), vec3(1, 4, 1));

pub fn translate(dv: vec2<T>) -> mat3<T>

Construct a translation matrix.

§Examples
let matrix = mat3::translate(vec2(3, 2));
assert_eq!(matrix * vec3(1, 2, 1), vec3(4, 4, 1));
§

impl<T> mat3<T>
where T: Float,

pub fn rotate(angle: Angle<T>) -> mat3<T>

Construct rotational matrix

pub fn rotate_around(p: vec2<T>, angle: Angle<T>) -> mat3<T>

Construct matrix that performs rotation around a specified point

§

impl<T> mat3<T>

pub fn map<U, F>(self, f: F) -> mat3<U>
where F: Fn(T) -> U,

Map every element

§

impl<T> mat3<T>
where T: Copy,

pub fn new(values: [[T; 3]; 3]) -> mat3<T>

Construct a matrix.

§Examples
let matrix = mat3::new([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]);

pub fn row(&self, row_index: usize) -> vec3<T>

Get row as a vec3

pub fn col(&self, col_index: usize) -> vec3<T>

Get column as a vec3

§

impl<T> mat3<T>

pub fn as_flat_array(&self) -> &[T; 9]

Get self as a flat array

pub fn as_flat_array_mut(&mut self) -> &mut [T; 9]

Get self as a mutable flat array

§

impl<T> mat3<T>
where T: Num + Copy,

pub fn zero() -> mat3<T>

Construct zero matrix.

§Examples
let matrix = mat3::<i32>::zero();
for i in 0..3 {
    for j in 0..3 {
        assert_eq!(matrix[(i, j)], 0);
    }
}

pub fn identity() -> mat3<T>

Construct identity matrix.

§Examples
let matrix = mat3::<i32>::identity();
for i in 0..3 {
    for j in 0..3 {
        assert_eq!(matrix[(i, j)], if i == j { 1 } else { 0 });
    }
}

Trait Implementations§

§

impl<T> Add for mat3<T>
where T: Num + Copy,

§

type Output = mat3<T>

The resulting type after applying the + operator.
§

fn add(self, rhs: mat3<T>) -> mat3<T>

Performs the + operation. Read more
§

impl<T> AddAssign for mat3<T>
where T: Num + Copy + AddAssign,

§

fn add_assign(&mut self, rhs: mat3<T>)

Performs the += operation. Read more
§

impl<T> Approx for mat3<T>
where T: Float,

§

fn approx_distance_to(&self, other: &mat3<T>) -> f32

Get an approximated distance between two values
§

fn approx_eq(&self, other: &Self) -> bool

Check if values are approximately equal using DEFAULT_EPS
§

fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool

Check if values are approximately equal using supplied eps value
§

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

§

fn clone(&self) -> mat3<T>

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
§

impl<T> Debug for mat3<T>
where T: Debug,

§

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

Formats the value using the given formatter. Read more
§

impl<'de, T> Deserialize<'de> for mat3<T>
where T: Deserialize<'de>,

§

fn deserialize<__D>( __deserializer: __D ) -> Result<mat3<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl<T> Div<T> for mat3<T>
where T: Num + Copy,

§

type Output = mat3<T>

The resulting type after applying the / operator.
§

fn div(self, rhs: T) -> mat3<T>

Performs the / operation. Read more
§

impl<T> DivAssign<T> for mat3<T>
where T: Num + Copy + DivAssign,

§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
§

impl<T> Index<(usize, usize)> for mat3<T>

§

type Output = T

The returned type after indexing.
§

fn index(&self, _: (usize, usize)) -> &T

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

impl<T> IndexMut<(usize, usize)> for mat3<T>

§

fn index_mut(&mut self, _: (usize, usize)) -> &mut T

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

impl<T> Mul<T> for mat3<T>
where T: Num + Copy,

§

type Output = mat3<T>

The resulting type after applying the * operator.
§

fn mul(self, rhs: T) -> mat3<T>

Performs the * operation. Read more
§

impl<T> Mul<vec3<T>> for mat3<T>
where T: Num + Copy,

§

type Output = vec3<T>

The resulting type after applying the * operator.
§

fn mul(self, rhs: vec3<T>) -> vec3<T>

Performs the * operation. Read more
§

impl<T> Mul for mat3<T>
where T: Num + Copy + AddAssign,

§

type Output = mat3<T>

The resulting type after applying the * operator.
§

fn mul(self, rhs: mat3<T>) -> mat3<T>

Performs the * operation. Read more
§

impl<T> MulAssign<T> for mat3<T>
where T: Num + Copy + MulAssign,

§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
§

impl<T> MulAssign for mat3<T>
where T: Num + Copy + AddAssign,

§

fn mul_assign(&mut self, rhs: mat3<T>)

Performs the *= operation. Read more
§

impl<T> Neg for mat3<T>
where T: Num<Output = T> + Copy + Neg,

§

type Output = mat3<T>

The resulting type after applying the - operator.
§

fn neg(self) -> mat3<T>

Performs the unary - operation. Read more
§

impl<T> Serialize for mat3<T>
where T: Serialize,

§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

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

impl<T> Sub for mat3<T>
where T: Num + Copy,

§

type Output = mat3<T>

The resulting type after applying the - operator.
§

fn sub(self, rhs: mat3<T>) -> mat3<T>

Performs the - operation. Read more
§

impl<T> SubAssign for mat3<T>
where T: Num + Copy + SubAssign,

§

fn sub_assign(&mut self, rhs: mat3<T>)

Performs the -= operation. Read more
source§

impl Uniform for mat3<f32>

source§

fn apply(&self, gl: &Context, info: &UniformInfo)

source§

impl VertexAttribute for mat3<f32>

§

impl<T> Copy for mat3<T>
where T: Copy,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for mat3<T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for mat3<T>
where T: Unpin,

§

impl<T> UnwindSafe for mat3<T>
where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> Downcast for T
where T: 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.
§

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.
§

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.
§

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.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

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

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

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

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

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

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

source§

impl<T> Message for T
where T: Debug + Serialize + for<'de> Deserialize<'de> + Send + 'static + Unpin,