Struct gfx_maths::mat4::Mat4[][src]

#[repr(C)]
pub struct Mat4 { pub values: [f32; 16], }
Expand description

A struct representing a 4x4 matrix.

It’s values are stored in column-major order by default, as expected by OpenGL and accepted by all other APIs. To change this, use feature mat-row-major

Fields

values: [f32; 16]

Implementations

Creates the identity matrix.

Creates a 3D translation matrix.

Creates a 3D rotation matrix.

Creates a 3D scale matrix.

Creates a 3D local-to-world/object-to-world matrix.

When multiplying this matrix by a vector, it will be

  • scaled by s
  • rotated by r
  • translated by t

in this order.

Creates a 3D world-to-local/world-to-object matrix.

This matrix does the opposite of local_to_world()

Creates an orthographic projection matrix with z mapped to [0; 1], as expected by Vulkan.

Creates an inverse orthographics projection matrix with z mapped to [0; 1], as expected by Vulkan.

The world position of a uv/depth pair can be reconstructed with the same code as shown in inverse_perspective_vulkan()

Creates a perspective projection matrix with z mapped to [0; 1], as expected by Vulkan.

Creates an inverse perspective matrix with z mapped to [0; 1], as expected by Vulkan.

This matrix can be used to reconstruct the world position from a uv/depth pair in a shader. This pseudo code can be used:

vec4 clipPos = vec4(uv.xy, depth, 1.0);
vec4 worldPos = invProjection * clipPos;
worldPos /= worldPos.w;

Returns a value indexed by column and row

Sets the value indexed by column and row to val

Returns a transposed copy of self.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Creates the identity matrix.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.