#[repr(C)]pub struct Mat4 {
pub data: [[f32; 4]; 4],
}Expand description
4x4 matrix for transforms.
Fields§
§data: [[f32; 4]; 4]Row-major matrix data [row][col]
Implementations§
Source§impl Mat4
impl Mat4
Sourcepub const fn translation(x: f32, y: f32, z: f32) -> Self
pub const fn translation(x: f32, y: f32, z: f32) -> Self
Create translation matrix.
Sourcepub const fn translation_2d(x: f32, y: f32) -> Self
pub const fn translation_2d(x: f32, y: f32) -> Self
Create 2D translation matrix.
Sourcepub const fn scale_uniform(s: f32) -> Self
pub const fn scale_uniform(s: f32) -> Self
Create uniform scale matrix.
Sourcepub fn rotation_z(angle_rad: f32) -> Self
pub fn rotation_z(angle_rad: f32) -> Self
Create rotation around Z axis (2D rotation).
Sourcepub fn ortho(
left: f32,
right: f32,
bottom: f32,
top: f32,
near: f32,
far: f32,
) -> Self
pub fn ortho( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> Self
Create orthographic projection matrix.
Sourcepub fn ortho_screen(width: f32, height: f32) -> Self
pub fn ortho_screen(width: f32, height: f32) -> Self
Create orthographic projection for screen coordinates (Y down).
Sourcepub fn transform_vec4(&self, v: Vec4) -> Vec4
pub fn transform_vec4(&self, v: Vec4) -> Vec4
Transform a Vec4.
Sourcepub fn transform_point(&self, p: Point) -> Point
pub fn transform_point(&self, p: Point) -> Point
Transform a 2D point (assumes z=0, w=1).
Sourcepub fn transform_rect(&self, rect: &Rect) -> Rect
pub fn transform_rect(&self, rect: &Rect) -> Rect
Transform a rectangle.
Trait Implementations§
impl Copy for Mat4
impl StructuralPartialEq for Mat4
Auto Trait Implementations§
impl Freeze for Mat4
impl RefUnwindSafe for Mat4
impl Send for Mat4
impl Sync for Mat4
impl Unpin for Mat4
impl UnwindSafe for Mat4
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
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().