Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Mat3I16

Struct Mat3I16 

Source
#[repr(C)]
pub struct Mat3I16 { pub m: [[i16; 3]; 3], }
Expand description

3×3 rotation / light matrix of i16 in 1.3.12. Laid out row-major so m[row][col] matches PSX-SPX notation (M_rc).

Fields§

§m: [[i16; 3]; 3]

Row-major 3×3 cells.

Implementations§

Source§

impl Mat3I16

Source

pub const ZERO: Mat3I16

Zero matrix.

Source

pub const IDENTITY: Mat3I16

Identity matrix scaled 1.0 in 1.3.12 (diagonal = 0x1000).

Source

pub const fn row(&self, i: usize) -> [i16; 3]

Access a row.

Source§

impl Mat3I16

Source

pub fn mul(&self, other: &Mat3I16) -> Mat3I16

Matrix × matrix, with 1.3.12 fixed-point scaling applied so the output stays in 1.3.12. Saturates each cell to i16 range – rotation compositions stay well within, but callers doing scale-by-100 before compose should watch for truncation.

Source

pub fn rotate_xyz(x: u16, y: u16, z: u16) -> Mat3I16

Compose X, then Y, then Z rotations using the PS1 matrix convention.

Angles use the same 256-per-revolution units as Self::rotate_x. The explicit order matters for camera/model transforms with more than one non-zero Euler component.

Source

pub fn scale_rows_q12(&self, scale: [i32; 3]) -> Mat3I16

Scale matrix rows by independent Q12 factors.

This matches the classic PS1 ScaleMatrixL convention: row 0 receives X, row 1 receives Y, and row 2 receives Z. Results saturate like the GTE IR registers instead of wrapping at i16 boundaries.

Source

pub fn scale_columns_q12(&self, scale: [i32; 3]) -> Mat3I16

Scale matrix columns by independent Q12 factors.

This matches the classic PS1 ScaleMatrix convention: column 0 receives X, column 1 receives Y, and column 2 receives Z.

Source

pub fn transform(&self, v: Vec3I16) -> [i32; 3]

Matrix × vector, with 1.3.12 scaling. Returns i32 per component so the caller can inspect the un-saturated product (useful for normal generation / light calculations before feeding back into the GTE as V0).

Source

pub fn transform_i32(&self, v: [i32; 3]) -> [i32; 3]

Matrix times a wide vector, using wrapping i32 dot products followed by an arithmetic Q12 shift. Inputs should keep each dot product in i32 when a non-wrapping result is required.

Source

pub fn rotate_x_q12(angle: u16) -> Mat3I16

X rotation in 4096-per-turn units, with interpolated Q12 trig.

Source

pub fn rotate_y_q12(angle: u16) -> Mat3I16

Y rotation in 4096-per-turn units, with interpolated Q12 trig.

Source

pub const fn rotate_x(angle: u16) -> Mat3I16

Rotation around the X axis by angle (256-per-revolution units).

  | 1    0     0  |
  | 0   cos  -sin |
  | 0   sin   cos |
Source

pub const fn rotate_y(angle: u16) -> Mat3I16

Rotation around the Y axis.

  |  cos  0  sin |
  |   0   1   0  |
  | -sin  0  cos |
Source

pub const fn rotate_z(angle: u16) -> Mat3I16

Rotation around the Z axis.

  | cos  -sin  0 |
  | sin   cos  0 |
  |  0     0   1 |

Trait Implementations§

Source§

impl Clone for Mat3I16

Source§

fn clone(&self) -> Mat3I16

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 Mat3I16

Source§

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

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

impl Default for Mat3I16

Source§

fn default() -> Mat3I16

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

impl PartialEq for Mat3I16

Source§

fn eq(&self, other: &Mat3I16) -> 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 Copy for Mat3I16

Source§

impl Eq for Mat3I16

Source§

impl StructuralPartialEq for Mat3I16

Auto Trait Implementations§

§

impl Freeze for Mat3I16

§

impl RefUnwindSafe for Mat3I16

§

impl Send for Mat3I16

§

impl Sync for Mat3I16

§

impl Unpin for Mat3I16

§

impl UnsafeUnpin for Mat3I16

§

impl UnwindSafe for Mat3I16

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

§

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.