View Source Graphmath.Mat33 (graphmath v2.6.0)
This is the 3D mathematics.
This submodule handles 3x3 matrices using tuples of floats.
Summary
Functions
add(a,b) adds one mat33 to another mat33.
apply( a, v ) transforms a vec3 by a mat33.
apply_left( v, a ) transforms a vec3 by a mat33, applied on the left.
apply_left_transpose( v, a ) transforms a vec3 by a transposed mat33, applied on the left.
apply_transpose( a, v ) transforms a vec3 by a a transposed mat33.
at( a, i, j) selects an element of a mat33.
column0( a ) selects the first column of a mat33.
column1( a ) selects the second column of a mat33.
column2( a ) selects the third column of a mat33.
diag( a ) selects the diagonal of a mat33.
identity() creates an identity mat33.
inverse(a) calculates the inverse matrix
make_rotate( theta ) creates a mat33 that rotates a vec2 by theta radians about the +Z axis.
make_scale( k ) creates a mat33 that uniformly scales.
make_scale( sx, sy, sz ) creates a mat33 that scales each axis independently.
make_translate( tx, ty ) creates a mat33 that translates a vec2 by (tx, ty).
multiply( a, b ) multiply two matrices a and b together.
multiply_transpose( a, b ) multiply two matrices a and b<sup>T</sup> together.
round( a, sigfigs ) rounds every element of a mat33 to some number of decimal places.
row0( a ) selects the first row of a mat33.
row1( a ) selects the second row of a mat33.
row2( a ) selects the third row of a mat33.
scale( a, k ) scales every element in a mat33 by a coefficient k.
subtract(a,b) subtracts one mat33 from another mat33.
transform_point( a, v ) transforms a vec2 point by a mat33.
transform_vector( a, v ) transforms a vec2 vector by a mat33.
zero() creates a zeroed mat33.
Types
Functions
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 ) transforms a vec3 by a mat33.
a is the mat33 to transform by.
v is the vec3 to be transformed.
This returns a vec3 representing A**v**.
This is the "full" application of a matrix, and uses all elements.
apply_left( v, a ) transforms a vec3 by a mat33, applied on the left.
a is the mat33 to transform by.
v is the vec3 to be transformed.
This returns a vec3 representing v**A**.
This is the "full" application of a matrix, and uses all elements.
apply_left_transpose( v, a ) transforms a vec3 by a transposed mat33, applied on the left.
a is the mat33 to transform by.
v is the vec3 to be transformed.
This returns a vec3 representing v**A**<sup>T</sup>.
This is the "full" application of a matrix, and uses all elements.
apply_transpose( a, v ) transforms a vec3 by a a transposed mat33.
a is the mat33 to transform by.
v is the vec3 to be transformed.
This returns a vec3 representing A<sup>T</sup>v.
This is the "full" application of a matrix, and uses all elements.
at( a, i, j) selects an element of a mat33.
a is the mat33 to index.
i is the row integer index [0,2].
j is the column integer index [0,2].
This returns a float from the matrix at row i and column j.
column0( a ) selects the first column of a mat33.
a is the mat33 to take the first column of.
This returns a vec3 representing the first column of a.
column1( a ) selects the second column of a mat33.
a is the mat33 to take the second column of.
This returns a vec3 representing the second column of a.
column2( a ) selects the third column of a mat33.
a is the mat33 to take the third column of.
This returns a vec3 representing the third column of a.
diag( a ) selects the diagonal of a mat33.
a is the mat33 to take the diagonal of.
This returns a vec3 representing the diagonal of a.
@spec identity() :: mat33()
identity() creates an identity mat33.
This returns an identity mat33.
inverse(a) calculates the inverse matrix
a is a mat33 to be inverted
Returs a mat33 representing a<sup>-1</sup>
Raises an error when you try to calculate inverse of a matrix whose determinant is zero
make_rotate( theta ) creates a mat33 that rotates a vec2 by theta radians about the +Z axis.
theta is the float of the number of radians of rotation the matrix will provide.
This returns a mat33 which rotates by theta radians about the +Z axis.
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 ) creates a mat33 that scales each axis independently.
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 methods, sz will have no effect.
make_translate( tx, ty ) creates a mat33 that translates a vec2 by (tx, ty).
tx is a float for translating along the x-axis.
ty is a float for translating along the y-axis.
This returns a mat33 which translates by a vec2 { tx, ty }.
multiply( a, b ) multiply two matrices a and b together.
a is the mat33 multiplicand.
b is the mat33 multiplier.
This returns the mat33 product of the a and b.
multiply_transpose( a, b ) multiply two matrices a and b<sup>T</sup> together.
a is the mat33 multiplicand.
b is the mat33 multiplier.
This returns the mat33 product of the a and b<sup>T</sup>.
round( a, sigfigs ) rounds every element of a mat33 to some number of decimal places.
a is the mat33 to round.
sigfigs is an integer on [0,15] of the number of decimal places to round to.
This returns a mat33 which is the result of rounding a.
row0( a ) selects the first row of a mat33.
a is the mat33 to take the first row of.
This returns a vec3 representing the first row of a.
row1( a ) selects the second row of a mat33.
a is the mat33 to take the second row of.
This returns a vec3 representing the second row of a.
row2( a ) selects the third row of a mat33.
a is the mat33 to take the third row of.
This returns a vec3 representing the third row of a.
scale( a, k ) scales every element in a mat33 by a 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) 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 ) transforms a vec2 point by a mat33.
a is a mat33 used to transform the point.
v is a vec2 to be transformed.
This returns a vec2 representing the application of a to v.
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 ) transforms a vec2 vector by a mat33.
a is a mat33 used to transform the point.
v is a vec2 to be transformed.
This returns a vec2 representing the application of a to v.
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.
@spec zero() :: mat33()
zero() creates a zeroed mat33.
This returns a zeroed mat33.