graphmath v1.0.4 Graphmath.Mat44
This is the 3D mathematics library for graphmath.
This submodule handles 4x4 matrices using tuples of floats.
Link to this section Summary
Functions
add(a,b)
adds one mat44
to another mat44
apply( a, v )
transforms a vec4
by a mat44
apply_left( v, a )
transforms a vec4
by a mat44
, 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 vec4
by a a transposed mat44
at( a, i, j)
selects an element of a mat44
column0( a )
selects the first column of a mat44
column1( a )
selects the second column of a mat44
column2( a )
selects the third column of a mat44
column3( a )
selects the fourth column of a mat44
diag( a )
selects the diagonal of a mat44
identity()
creates an identity mat44
inverse(a)
calculates the inverse matrix
make_rotate_x( theta )
creates a mat44
that rotates a vec3
by theta
radians about the +X axis
make_rotate_y( theta )
creates a mat44
that rotates a vec3
by theta
radians about the +Y axis
make_rotate_Z( theta )
creates a mat44
that rotates a vec3
by theta
radians about the +Z axis
make_scale( k )
creates a mat44
that uniformly scales
make_scale( sx, sy, sz, sw )
creates a mat44
that scales each axis independently
make_translate( tx, ty, tz )
creates a mat44 that translates a point by tx, ty, and tz
multiply( a, b )
multiply two matrices a and b together
multiply_transpose( a, b )
multiply two matrices a and bT together
round( a, sigfigs )
rounds every element of a mat44
to some number of decimal places
row0( a )
selects the first row of a mat44
row1( a )
selects the second row of a mat44
row2( a )
selects the third row of a mat44
row3( a )
selects the fourth row of a mat44
scale( a, k )
scales every element in a mat44
by a coefficient k
subtract(a,b)
subtracts one mat44
from another mat44
transform_point( a, v )
transforms a vec3
point by a mat44
transform_vector( a, v )
transforms a vec3
vector by a mat44
zero()
creates a zeroed mat44
Link to this section Types
Link to this section Functions
add(a, b)
add(a,b)
adds one mat44
to another mat44
.
a
is the first mat44
.
b
is the second mat44
.
This returns a mat44
which is the element-wise sum of a
and b
.
apply(a, v)
apply( a, v )
transforms a vec4
by a mat44
.
a
is the mat44
to transform by.
v
is the vec4
to be transformed.
This returns a vec4
representing A**v**.
This is the "full" application of a matrix, and uses all elements.
apply_left(v, a)
apply_left( v, a )
transforms a vec4
by a mat44
, applied on the left.
a
is the mat44
to transform by.
v
is the vec4
to be transformed.
This returns a vec4
representing v**A**.
This is the "full" application of a matrix, and uses all elements.
apply_left_transpose(v, a)
apply_left_transpose( v, a )
transforms a vec3
by a transposed mat33
, applied on the left.
a
is the mat44
to transform by.
v
is the vec4
to be transformed.
This returns a vec4
representing v**A**T.
This is the "full" application of a matrix, and uses all elements.
apply_transpose(a, v)
apply_transpose( a, v )
transforms a vec4
by a a transposed mat44
.
a
is the mat44
to transform by.
v
is the vec4
to be transformed.
This returns a vec4
representing ATv.
This is the "full" application of a matrix, and uses all elements.
at(a, i, j)
at( a, i, j)
selects an element of a mat44
.
a
is the mat44
to index.
i
is the row integer index [0,3].
j
is the column integer index [0,3].
This returns a float from the matrix at row i
and column j
.
column0(a)
column0( a )
selects the first column of a mat44
.
a
is the mat44
to take the first column of.
This returns a vec4
representing the first column of a
.
column1(a)
column1( a )
selects the second column of a mat44
.
a
is the mat44
to take the second column of.
This returns a vec4
representing the second column of a
.
column2(a)
column2( a )
selects the third column of a mat44
.
a
is the mat44
to take the third column of.
This returns a vec4
representing the third column of a
.
column3(a)
column3( a )
selects the fourth column of a mat44
.
a
is the mat44
to take the fourth column of.
This returns a vec4
representing the fourth column of a
.
diag(a)
diag( a )
selects the diagonal of a mat44
.
a
is the mat44
to take the diagonal of.
This returns a vec4
representing the diagonal of a
.
identity()
identity() :: mat44()
identity() :: mat44()
identity()
creates an identity mat44
.
This returns an identity mat44
.
inverse(a)
inverse(a)
calculates the inverse matrix
a
is a mat44
to be inverted
Returs a mat44
representing a
-1
Raises an error when you try to calculate inverse of a matrix whose determinant is zero
make_rotate_x(theta)
make_rotate_x( theta )
creates a mat44
that rotates a vec3
by theta
radians about the +X axis.
theta
is the float of the number of radians of rotation the matrix will provide.
This returns a mat44
which rotates by theta
radians about the +X axis.
make_rotate_y(theta)
make_rotate_y( theta )
creates a mat44
that rotates a vec3
by theta
radians about the +Y axis.
theta
is the float of the number of radians of rotation the matrix will provide.
This returns a mat44
which rotates by theta
radians about the +Y axis.
make_rotate_z(theta)
make_rotate_Z( theta )
creates a mat44
that rotates a vec3
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 mat44
which rotates by theta
radians about the +Z axis.
make_scale(k)
make_scale( k )
creates a mat44
that uniformly scales.
k
is the float value to scale by.
This returns a mat44
whose diagonal is all k
s.
make_scale(sx, sy, sz, sw)
make_scale( sx, sy, sz, sw )
creates a mat44
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.
sw
is a float for scaling the w-axis.
This returns a mat44
whose diagonal is { sx, sy, sz, sw }
.
Note that, when used with vec3
s via the transform methods, sw
will have no effect.
make_translate(tx, ty, tz)
make_translate( tx, ty, tz )
creates a mat44 that translates a point by tx, ty, and tz.
make_translate( tx, ty, tz )
creates a mat44 that translates a vec3 by (tx, ty, tz).
tx
is a float for translating along the x-axis.
ty
is a float for translating along the y-axis.
tz
is a float for translating along the z-axis.
This returns a mat44
which translates by a vec3
{ tx, ty, tz }
.
multiply(a, b)
multiply( a, b )
multiply two matrices a and b together.
a
is the mat44
multiplicand.
b
is the mat44
multiplier.
This returns the mat44
product of the a
and b
.
multiply_transpose(a, b)
multiply_transpose( a, b )
multiply two matrices a and bT together.
a
is the mat44
multiplicand.
b
is the mat44
multiplier.
This returns the mat44
product of the a
and b
T.
round(a, sigfigs)
round( a, sigfigs )
rounds every element of a mat44
to some number of decimal places.
a
is the mat44
to round.
sigfigs
is an integer on [0,15] of the number of decimal places to round to.
This returns a mat44
which is the result of rounding a
.
row0(a)
row0( a )
selects the first row of a mat44
.
a
is the mat44
to take the first row of.
This returns a vec4
representing the first row of a
.
row1(a)
row1( a )
selects the second row of a mat44
.
a
is the mat44
to take the second row of.
This returns a vec4
representing the second row of a
.
row2(a)
row2( a )
selects the third row of a mat44
.
a
is the mat44
to take the third row of.
This returns a vec4
representing the third row of a
.
row3(a)
row3( a )
selects the fourth row of a mat44
.
a
is the mat44
to take the fourth row of.
This returns a vec4
representing the fourth row of a
.
scale(a, k)
scale( a, k )
scales every element in a mat44
by a coefficient k.
a
is the mat44
to scale.
k
is the float to scale by.
This returns a mat44
a
scaled element-wise by k
.
subtract(a, b)
subtract(a,b)
subtracts one mat44
from another mat44
.
a
is the minuend.
b
is the subtraherd.
This returns a mat44
formed by the element-wise subtraction of b
from a
.
transform_point(a, v)
transform_point( a, v )
transforms a vec3
point by a mat44
.
a
is a mat44
used to transform the point.
v
is a vec3
to be transformed.
This returns a vec3
representing the application of a
to v
.
The point a
is internally treated as having a fourth coordinate equal to 1.0.
Note that transforming a point will work for all transforms.
transform_vector(a, v)
transform_vector( a, v )
transforms a vec3
vector by a mat44
.
a
is a mat44
used to transform the point.
v
is a vec3
to be transformed.
This returns a vec3
representing the application of a
to v
.
The point a
is internally treated as having a fourth coordinate equal to 0.0.
Note that transforming a vector will work for only rotations, scales, and shears.
zero()
zero() :: mat44()
zero() :: mat44()
zero()
creates a zeroed mat44
.
This returns a zeroed mat44
.