Import std.math.matrix
std.math.matrix
Mat3 and Mat4: matrices of Floats, column-major, as the GPU takes them. Each column is a Field, x, y, z, and w, a vector of where the matrix takes that axis, and the last of a Mat4 is where it takes the origin. m * v transforms v, and a * b transforms by b, then by a. The projections are right-handed, looking down -Z, with depth from 0 at near to 1 at far, as Vulkan's.
std/math/matrix.fb
Types
Mat3
struct
Public Struct Mat3 Implements Equatable, Printable
A 3 by 3 matrix: a rotation, a scale, or both, of 3D vectors.
-
Its first column.
-
Its second column.
-
Its third column.
-
The matrix that changes nothing.
-
The matrix that scales each axis by the vector's component.
-
The
rotation's matrix. -
The rotation by the
angle, in radians, about the X axis. -
The rotation by the
angle, in radians, about the Y axis. -
The rotation by the
angle, in radians, about the Z axis. -
The matrix as a Mat4 that moves nothing.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString. -
The element in a column and a row, each from 0 to 2. Any other panics.
-
The transform by
b, then bya. -
The vector transformed.
-
mtimesscale. -
scaletimesm. -
mdivided byscale. -
aplusb. -
aminusb.
Mat4
struct
Public Struct Mat4 Implements Equatable, Printable
A 4 by 4 matrix: an affine transform of 3D points, moving, turning, and scaling them, or a camera's projection.
-
Its first column.
-
Its second column.
-
Its third column.
-
Its fourth column, the translation.
-
The matrix that changes nothing.
-
The matrix that moves points by the vector.
-
The matrix that scales each axis by the vector's component.
-
The
rotation's matrix. -
The rotation by the
angle, in radians, about the X axis. -
The rotation by the
angle, in radians, about the Y axis. -
The rotation by the
angle, in radians, about the Z axis. -
The matrix that scales, then rotates, then moves, as an object's transform does: what Decompose takes apart.
-
@PanicsAtCaller Public Static Method LookAt(eye: Vec3, target: Vec3, up: Vec3): Mat4static method #The view matrix of a camera at
eyelooking attarget, with up toward the top of the view: it takes the world to where the camera, at the origin, looks down -Z. A target at theeye, or an up along the view, panics. -
@PanicsAtCaller Public Static Method Perspective(fieldOfView: Float, aspect: Float, near: Float, far: Float): Mat4static method #A perspective projection, with the field of view from the bottom of the view to its top, in radians, and the
aspect, its width over its height: depth goes from 0 atnearto 1 atfar. A field of view outside 0 to Pi, an aspect that isn't finite and above 0, or a near andfarthat aren't finite with 0 <near<far, panics. -
@PanicsAtCaller Public Static Method Orthographic(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float): Mat4static method #An orthographic projection of the box from
lefttoright,bottomtotop, andneartofarin front of the camera, to -1 to 1 across and up, and depth from 0 atnearto 1 atfar. A box whose sides aren't finite, or where two that face each other are at one place, panics. -
The
pointtransformed, with its w taken as 1, for a matrix that moves, turns, and scales. -
The
directiontransformed, with its w taken as 0, so the matrix turns and scales it but doesn't move it. -
The
pointtransformed by a projection, divided by the w it gives, as the GPU does. -
The translation, rotation, and scale that Compose makes the matrix of: a transform that flips gives a negative X scale. A matrix with no inverse, as one that scales to 0 has none, panics; its determinant is worked out in Doubles, so a tiny scale's isn't 0.
-
The upper left 3 by 3, which turns and scales.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString. -
The element in a column and a row, each from 0 to 3. Any other panics.
-
The transform by
b, then bya. -
The vector transformed.
-
mtimesscale. -
scaletimesm. -
mdivided byscale. -
aplusb. -
aminusb.
Functions
Transpose
function
Public Function Transpose(m: Mat3): Mat3
The matrix with its rows for columns.
Transpose
function
Public Function Transpose(m: Mat4): Mat4
The matrix with its rows for columns.
Determinant
function
Public Function Determinant(m: Mat3): Float
How the matrix scales volume, negative where it flips: 0 for one with no inverse. It's worked out in Doubles, which hold any three Floats' products, and rounded once.
Determinant
function
Public Function Determinant(m: Mat4): Float
How the matrix scales volume, negative where it flips: 0 for one with no inverse. It's worked out in Doubles, which hold any four Floats' products, and rounded once.
TryInverse
function
Public Function TryInverse(m: Mat3): Mat3?
The matrix that undoes this one, or Null for one with no inverse, whose determinant is 0. The inverse's rows are the cross products of the other two columns, over the determinant, worked out in Doubles, so a matrix of a tiny or huge scale inverts too.
TryInverse
function
Public Function TryInverse(m: Mat4): Mat4?
The matrix that undoes this one, or Null for one with no inverse, whose determinant is 0: the cofactors over the determinant, by the minors of the first two columns and the last two, as Geometric Tools expands them, in Doubles, so a matrix of a tiny or huge scale inverts too.
Inverse
function
@PanicsAtCaller Public Function Inverse(m: Mat3): Mat3
The matrix that undoes this one. One with no inverse, whose determinant is 0, panics.
Inverse
function
@PanicsAtCaller Public Function Inverse(m: Mat4): Mat4
The matrix that undoes this one. One with no inverse, whose determinant is 0, panics.
IsClose
function
Public Function IsClose(a: Mat3, b: Mat3): Bool
Whether each element is close to b's, as IsClose tells for Floats.
IsClose
function
Public Function IsClose(a: Mat4, b: Mat4): Bool
Whether each element is close to b's, as IsClose tells for Floats.
IsClose
function
Public Function IsClose(a: Mat3, b: Mat3, tolerance: Float): Bool
Whether each element is no further from b's than tolerance.
IsClose
function
Public Function IsClose(a: Mat4, b: Mat4, tolerance: Float): Bool
Whether each element is no further from b's than tolerance.
Report an issue with this page or with FutureBlitz on GitHub.