matrix/mat2f

2x2 matrices of floats

Types

Mat2f is a 2x2 column-major matrix of Floats.

pub type Mat2f =
  vec2.Vec2(vec2.Vec2(Float))

Values

pub fn add(
  a: vec2.Vec2(vec2.Vec2(Float)),
  b: vec2.Vec2(vec2.Vec2(Float)),
) -> vec2.Vec2(vec2.Vec2(Float))

Adds two Mat2f together.

pub fn determinant(mat: vec2.Vec2(vec2.Vec2(Float))) -> Float

Returns the determinant for the Mat2f.

pub fn divide(
  a: vec2.Vec2(vec2.Vec2(Float)),
  b: vec2.Vec2(vec2.Vec2(Float)),
) -> Result(vec2.Vec2(vec2.Vec2(Float)), Nil)

Divides one Mat2f by another. Equivalent to multiplying the inverse of the second matrix.

pub fn from_angle(angle: Float) -> vec2.Vec2(vec2.Vec2(Float))

Constructs a Mat2f from a rotation angle in radians.

pub fn from_cols(
  a: vec2.Vec2(Float),
  b: vec2.Vec2(Float),
) -> vec2.Vec2(vec2.Vec2(Float))

Constructs a Mat2f from its two columns.

| ax  bx |
| ay  by |
pub fn from_diagonal(
  diag: vec2.Vec2(Float),
) -> vec2.Vec2(vec2.Vec2(Float))

Constructs a Mat2f with the given diagonal and all other entries set to 0.

| x    0.0 |
| 0.0  y   |
pub fn from_scale_angle(
  scale: vec2.Vec2(Float),
  angle: Float,
) -> vec2.Vec2(vec2.Vec2(Float))

Constructs a Mat2f from scale factor (as a Vec2f) and a rotation in radians.

pub const identity: vec2.Vec2(vec2.Vec2(Float))

A Mat2f representing the identity, i.e. 1.0 is on the diagonal.

pub fn inverse(
  mat: vec2.Vec2(vec2.Vec2(Float)),
) -> Result(vec2.Vec2(vec2.Vec2(Float)), Nil)

Inverts the Mat2f, returning an error if the determinant is zero.

pub fn mul_transpose_vec2(
  mat: vec2.Vec2(vec2.Vec2(Float)),
  rhs: vec2.Vec2(Float),
) -> vec2.Vec2(Float)

Transforms a Vec2f by the transpose of this Mat2f.

pub fn mul_vec2(
  mat: vec2.Vec2(vec2.Vec2(Float)),
  rhs: vec2.Vec2(Float),
) -> vec2.Vec2(Float)

Transforms a Vec2f by this Mat2f.

pub fn multiply(
  a: vec2.Vec2(vec2.Vec2(Float)),
  b: vec2.Vec2(vec2.Vec2(Float)),
) -> vec2.Vec2(vec2.Vec2(Float))

Multiplies two Mat2f together.

pub fn negate(
  mat: vec2.Vec2(vec2.Vec2(Float)),
) -> vec2.Vec2(vec2.Vec2(Float))

Negates all elements of the Mat2f

pub fn new(
  a: Float,
  b: Float,
  c: Float,
  d: Float,
) -> vec2.Vec2(vec2.Vec2(Float))

Constructs a Mat2f from its components:

| a  c |
| b  d |
pub fn scale(
  mat: vec2.Vec2(vec2.Vec2(Float)),
  scale: Float,
) -> vec2.Vec2(vec2.Vec2(Float))

Scales the Mat2f by a Float factor.

pub fn scale_diagonal(
  mat: vec2.Vec2(vec2.Vec2(Float)),
  scale: vec2.Vec2(Float),
) -> vec2.Vec2(vec2.Vec2(Float))

Scales the Mat2f by a Vec2f.

This is faster than creating a diagonal scaling matrix and then multiplying that.

pub fn subtract(
  a: vec2.Vec2(vec2.Vec2(Float)),
  b: vec2.Vec2(vec2.Vec2(Float)),
) -> vec2.Vec2(vec2.Vec2(Float))

Subtracts one Mat2f from the other.

pub fn transpose(
  mat: vec2.Vec2(vec2.Vec2(Float)),
) -> vec2.Vec2(vec2.Vec2(Float))

Transposes the Mat2f along the diagonal.

pub const zero: vec2.Vec2(vec2.Vec2(Float))

A Mat2f with all elements set to 0.0

Search Document