pub struct Projection { /* private fields */ }Expand description
Representation of a projection matrix.
Projection matrices may be identity projections, which are normalized device coordinates, perspective projections, or orthographic projections.
Implementations§
source§impl Projection
impl Projection
sourcepub fn orthographic(space: ClipSpace) -> Self
pub fn orthographic(space: ClipSpace) -> Self
Computes an orthographic projection from the specified clip-space information.
§Parameters
space- The clip-space information.
Methods from Deref<Target = Mat4>§
pub const COLS: usize = 4usize
pub const ROWS: usize = 4usize
sourcepub fn as_array_slice(&self) -> &[[f32; 4]]
pub fn as_array_slice(&self) -> &[[f32; 4]]
sourcepub fn as_array_ref(&self) -> &[[f32; 4]; 4]
pub fn as_array_ref(&self) -> &[[f32; 4]; 4]
sourcepub fn to_matrix4(&self) -> Matrix4
pub fn to_matrix4(&self) -> Matrix4
sourcepub fn row(&self, index: usize) -> &Vec4
pub fn row(&self, index: usize) -> &Vec4
Returns the row at the given index.
This function will panic if the given index is out of bounds.
§Parameters
index- The index of the row to return.
sourcepub unsafe fn row_unchecked(&self, index: usize) -> &Vec4
pub unsafe fn row_unchecked(&self, index: usize) -> &Vec4
sourcepub fn col(&self, index: usize) -> &Col4
pub fn col(&self, index: usize) -> &Col4
Returns the column at the given index.
This function will panic if the given index is out of bounds.
§Parameters
index- The index of the column to return.
sourcepub unsafe fn col_unchecked(&self, index: usize) -> &Col4
pub unsafe fn col_unchecked(&self, index: usize) -> &Col4
Returns the column at the given index without performing bounds checking.
Note: Unlike Mat4::row_unchecked, this function returns an owning
Vector4 instead of a reference of Vec4.
§Safety
This function is unsafe because it does not check that the given index is less than 4. If this constraint is violated, memory safety errors can occur.
§Parameters
index- The index of the column to return.
sourcepub fn get(&self, row: usize, col: usize) -> f32
pub fn get(&self, row: usize, col: usize) -> f32
Returns the value at the given column and row.
This function will panic if the given index is out of bounds.
§Parameters
row- The index of the row to return.col- The index of the column to return.
sourcepub unsafe fn get_unchecked(&self, row: usize, col: usize) -> f32
pub unsafe fn get_unchecked(&self, row: usize, col: usize) -> f32
Returns the value at the given column and row without performing bounds checking.
§Safety
This function is unsafe because it does not check that the given index is less than 4. If this constraint is violated, memory safety errors can occur.
§Parameters
row- The index of the row to return.col- The index of the column to return.
sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Returns the determinant of the matrix.
sourcepub fn transposed(&self) -> Matrix4
pub fn transposed(&self) -> Matrix4
Returns the transpose of the matrix.
sourcepub fn mul_mat4(&self, other: &Mat4) -> Matrix4
pub fn mul_mat4(&self, other: &Mat4) -> Matrix4
Combines this matrix with another matrix by performing matrix multiplication.
§Parameters
other- The matrix to combine with.
sourcepub fn mul_col_vec4(&self, vec: &Vec4) -> Vector4
pub fn mul_col_vec4(&self, vec: &Vec4) -> Vector4
Combines this matrix with a column vector, returning the resultant vector.
This implements matrix-vector of:
| a b c d | | x | | ax + by + cz + dw |
| e f g h | * | y | = | ex + fy + gz + hw |
| i j k l | | z | | ix + jy + kz + lw |
| m n o p | | w | | mx + ny + oz + pw |§Parameters
vec- The vector to combine with.
sourcepub fn mul_row_vec4(&self, vec: &Vec4) -> Vector4
pub fn mul_row_vec4(&self, vec: &Vec4) -> Vector4
Combines this matrix with a row vector, returning the resultant vector.
This implements vector-matrix multiplication of:
| x y z w | | a b c d | | ax + ey + iz + mw |
* | e f g h | = | bx + fy + jz + nw |
| i j k l | | cx + gy + kz + ow |
| m n o p | | dx + hy + lz + pw |