Graphmath.Mat33

This is the 3D mathematics library for graphmath.

This submodule handles 3x3 matrices using tuples of floats.

Summary

add(a, b)

add(a,b) adds one mat33 to another mat33

apply(a, v)

apply( a, v ) transforms a vector v by a 3x3 matrix a

apply_left(v, a)

apply_left( v, a ) transforms a vector v by a 3x3 matrix a

apply_left_transpose(v, a)

apply_left_transpose( v, a ) transforms a vector v by a 3x3 matrix a transposed

apply_transpose(a, v)

apply_transpose( a, v ) transforms a vector v by a 3x3 matrix a transposed

at(a, i, j)

at( a, i, j) selects the element of a 3x3 matrix at row i and column j

column0(a)

column0( a ) selects the first column from a matrix 3x3 as a vec3

column1(a)

column1( a ) selects the second column from a matrix 3x3 as a vec3

column2(a)

column2( a ) selects the third column from a matrix 3x3 as a vec3

diag(a)

diag( a ) selects the diagonal from a matrix 3x3 as a vec3

identity()

identity() creates an identity mat33

make_rotate(theta)

make_rotate( theta ) creates a mat33 that rotates a vec2 by theta radians about the Z axis

make_scale(k)

make_scale( k ) creates a mat33 that uniformly scales

make_scale(sx, sy, sz)

make_scale( sx, sy, sz ) creates a mat33 that scales by sx, sy, and sz

make_translate(tx, ty)

make_translate( tx, ty ) creates a mat33 that translates a vec2 by (tx, ty)

multiply(a, b)

multiply( a, b ) multiply two matrices a and b together

multiply_transpose(a, b)

multiply_transpose( a, b ) multiply two matrices a and b transpose together

round(a, sigfigs)

round( a, sigfigs ) rounds every element of a supplied mat33 a to number of digits sigfigs

row0(a)

row0( a ) selects the first row from a matrix 3x3 as a vec3

row1(a)

row1( a ) selects the second row from a matrix 3x3 as a vec3

row2(a)

row2( a ) selects the third row from a matrix 3x3 as a vec3

scale(a, k)

scale( a, k ) scales every element in a matrix a by coefficient k

subtract(a, b)

subtract(a,b) subtracts one mat33 from another mat33

transform_point(a, v)

transform_point( a, v ) transforms a vec2 point v by a matrix a

transform_vector(a, v)

transform_vector( a, v ) transforms a vec2 vector v by a matrix a

zero()

zero() creates a zeroed mat33

Types

mat33 :: {float, float, float, float, float, float, float, float, float}

vec3 :: {float, float, float}

vec2 :: {float, float}

Functions

add(a, b)

Specs:

add(a,b) adds one mat33 to another mat33.

a is the first mat33.

b is the second mat33.

This returns a mat33 which is the element-wise sum of a and b.

apply(a, v)

Specs:

apply( a, v ) transforms a vector v by a 3x3 matrix a.

apply_left(v, a)

Specs:

apply_left( v, a ) transforms a vector v by a 3x3 matrix a.

apply_left_transpose(v, a)

Specs:

apply_left_transpose( v, a ) transforms a vector v by a 3x3 matrix a transposed.

apply_transpose(a, v)

Specs:

apply_transpose( a, v ) transforms a vector v by a 3x3 matrix a transposed.

at(a, i, j)

Specs:

  • at(mat33, Integer, Integer) :: float

at( a, i, j) selects the element of a 3x3 matrix at row i and column j.

column0(a)

Specs:

column0( a ) selects the first column from a matrix 3x3 as a vec3.

column1(a)

Specs:

column1( a ) selects the second column from a matrix 3x3 as a vec3.

column2(a)

Specs:

column2( a ) selects the third column from a matrix 3x3 as a vec3.

diag(a)

Specs:

diag( a ) selects the diagonal from a matrix 3x3 as a vec3.

identity()

Specs:

identity() creates an identity mat33.

This returns an identity mat33.

make_rotate(theta)

Specs:

  • make_rotate(float) :: mat33

make_rotate( theta ) creates a mat33 that rotates a vec2 by theta radians about the Z axis.

make_scale(k)

Specs:

  • make_scale(float) :: mat33

make_scale( k ) creates a mat33 that uniformly scales.

k is the float value to scale by.

This returns a mat33 whose diagonal is all ks.

make_scale(sx, sy, sz)

Specs:

  • make_scale(float, float, float) :: mat33

make_scale( sx, sy, sz ) creates a mat33 that scales by sx, sy, and sz.

sx is a float for scaling the x-axis.

sy is a float for scaling the y-axis.

sz is a float for scaling the z-axis.

This returns a mat33 whose diagonal is { sx, sy, sz }.

Note that, when used with vec2s via the transform method, sz will have no effect.

make_translate(tx, ty)

Specs:

  • make_translate(float, float) :: mat33

make_translate( tx, ty ) creates a mat33 that translates a vec2 by (tx, ty).

multiply(a, b)

Specs:

multiply( a, b ) multiply two matrices a and b together.

multiply_transpose(a, b)

Specs:

multiply_transpose( a, b ) multiply two matrices a and b transpose together.

round(a, sigfigs)

Specs:

round( a, sigfigs ) rounds every element of a supplied mat33 a to number of digits sigfigs.

row0(a)

Specs:

row0( a ) selects the first row from a matrix 3x3 as a vec3.

row1(a)

Specs:

row1( a ) selects the second row from a matrix 3x3 as a vec3.

row2(a)

Specs:

row2( a ) selects the third row from a matrix 3x3 as a vec3.

scale(a, k)

Specs:

scale( a, k ) scales every element in a matrix a by coefficient k.

a is the mat33 to scale.

k is the float to scale by.

This returns a mat33 a scaled element-wise by k.

subtract(a, b)

Specs:

subtract(a,b) subtracts one mat33 from another mat33.

a is the minuend.

b is the subtraherd.

This returns a mat33 formed by the element-wise subtraction of b from a.

transform_point(a, v)

Specs:

transform_point( a, v ) transforms a vec2 point v by a matrix a.

The point a is internally treated as having a third coordinate equal to 1.0.

Note that transforming a point will work for all transforms.

transform_vector(a, v)

Specs:

transform_vector( a, v ) transforms a vec2 vector v by a matrix a.

The point a is internally treated as having a third coordinate equal to 0.0.

Note that transforming a vector will work for only rotations, scales, and shears.

zero()

Specs:

zero() creates a zeroed mat33.

This returns a zeroed mat33.