A mat3 represents a 3x3 matrix which can be used to store linear transformations (if you want to store translations or perspective transformations, you have to use a mat4). You can construct a mat3 in several ways:
# all components are set to zero
M = mat3()
[ 0.0000, 0.0000, 0.0000]
[ 0.0000, 0.0000, 0.0000]
[ 0.0000, 0.0000, 0.0000]
# identity matrix
M = mat3(1.0)
[ 1.0000, 0.0000, 0.0000]
[ 0.0000, 1.0000, 0.0000]
[ 0.0000, 0.0000, 1.0000]
# The elements on the diagonal are set to 2.5
M = mat3(2.5)
[ 2.5000, 0.0000, 0.0000]
[ 0.0000, 2.5000, 0.0000]
[ 0.0000, 0.0000, 2.5000]
# All elements are explicitly set (values must be given in row-major order)
M = mat3(a,b,c,d,e,f,g,h,i)
M = mat3([a,b,c,d,e,f,g,h,i])
[ a, b, c]
[ d, e, f]
[ g, h, i]
# Create a copy of matrix N (which also has to be a mat3)
M = mat3(N)
# Specify the 3 columns of the matrix (as vec3's or sequences with 3 elements)
M = mat3(a,b,c)
[ a[0], b[0], c[0] ]
[ a[1], b[1], c[1] ]
[ a[2], b[2], c[2] ]
# All elements are explicitly set and are stored inside a string
M = mat3("1,2,3,4,5,6,7,8,9")
[ 1.0000, 2.0000, 3.0000]
[ 4.0000, 5.0000, 6.0000]
[ 7.0000, 8.0000, 9.0000]
Mathematical operations
The mathematical operators are supported with the following combination of types:
mat3 = mat3 + mat3 mat3 = mat3 - mat3 mat3 = mat3 * mat3 vec3 = mat3 * vec3 vec3 = vec3 * mat3 mat3 = float * mat3 mat3 = mat3 * float mat3 = mat3 / float mat3 = mat3 % float # each component mat3 = -mat3 vec3 = mat3[i] # get or set column i (as vec3) float = mat3[i,j] # get or set element in row i and column j
Additionally, you can compare matrices with == and !=.
Methods
| index) |
| index, value) |
| index) |
| index, value) |
| ) |
| value) |
| rowmajor=False) |
True, you'll get the list in row-major order.
| ) |
| ) |
| ) |
| ) |
| s) |
This is a static method.
| angle, axis) |
| s) |
| angle, axis) |
| ) |
| ) |
| x, y, z) |
| x, y, z) |
| x, y, z) |
| x, y, z) |
| x, y, z) |
| x, y, z) |
| ) |
| ) |
| ) |
| ) |
| ) |
| ) |
| _from, to) |
This method is based on the code from:
Tomas Möller and John Hughes
Efficiently Building a Matrix to Rotate One Vector to Another
Journal of Graphics Tools, 4(4):1-4, 1999
http://www.acm.org/jgt/papers/MollerHughes99/
This is a static method.