Matrices
The geom module defines matrices in two, three and four dimensions.
All matrices store the values in rowmajor order, meaning that, the matrix ((1,
2), (3,4)) stores the values as (1, 2, 3, 4). This is illustrated in
the following code examples:
m=geom.Mat2(1, 2, 3, 4)
print(m) # will print {{1,2},{3,4}}
print(m[(0,0)], m[(0,1)], m[(1,0)], m[(1,1)]) # will print 1, 2, 3, 4
Matrices support arithmetic via overloaded operators. The following operations are
supported:
 adding and subtracting two matrices
 negation
 multiplication of matrices
 multiplying and dividing by scalar value
The Matrix Classes

class
Mat2

class
Mat2 (d00, d01, d10, d11)
2x2 realvalued matrix. The first signature creates a new identity matrix. The
second signature initializes the matrix in rowmajor order.

static
Identity ()
Returns the 2x2 identity matrix

class
Mat3

class
Mat3 (d00, d01, d02, d10, d11, d12, d20, d21, d22)
3x3 realvalued matrix. The first signature creates a new identity matrix. The
second signature initializes the matrix in rowmajor order.

static
Identity ()
Returns the 3x3 identity matrix

class
Mat4

class
Mat4 (d00, d01, d02, d03, d10, d11, d12, d13, d20, d21, d22, d23, d30, d31, d32, d33)
4x4 realvalued matrix. The first signature creates a new identity matrix. The
second signature initializes the matrix in rowmajor order.
Returns the 3x3 submatrix

PasteRotation (mat)
Set the 3x3 submatrix of the topleft corner to mat
Extract translation component from matrix. Only meaningful when matrix
is a combination of rotation and translation matrices, otherwise the result
is undefined.

static
Identity ()
Returns the 4x4 identity matrix
Functions Operating on Matrices

Equal (lhs, rhs, epsilon=geom.EPSILON)
Compares the two matrices lhs and rhs and returns True, if all
of the elementwise differences are smaller than epsilon. lhs
and rhs must be matrices of the same dimension.

Transpose (mat)
Returns the transpose of mat
Parameters:  mat – The matrix to be transposed 

Invert (mat)
Returns the inverse of mat
Parameters:  mat (Mat2 , Mat3 or Mat4 ) – The matrix to be inverted 
What happens when determinant is 0?

CompMultiply (lhs, rhs)
Returns the componentwise product of lhs and rhs. lhs and
rhs must be vectors of the same dimension.

CompDivide (lhs, rhs)
Returns the componentwise quotient of lhs divided by rhs. lhs
and rhs must be vectors of the same dimension.

Det (mat)
Returns the determinant of mat
:param mat: A matrix
:type mat: Mat2 , Mat3 or Mat4

Minor (mat, i, j)
Returns the determinant of the 2x2 matrix generated from mat by
removing the ith row and jth column.

EulerTransformation (phi, theta, xi)
Returns a rotation matrix for the 3 euler angles phi, theta, and
xi. The 3 angles are given in radians.

AxisRotation (axis, angle)
Returns a rotation matrix that represents a rotation of angle
around the axis.
Parameters: 
 axis (
Vec3 ) – The rotation axis. Will be normalized
 angle – Rotation angle (radians) in clockwise direction when
looking down the axis.


OrthogonalVector (vec)
Get arbitrary vector orthogonal to vec. The returned vector is of length
1, except when vec is a zero vector. In that case, the returned vector is
(0, 0, 0).
Parameters:  vec (Vec3 ) – A vector of arbitrary length 

Contents
Search
Enter search terms or a module, class or function name.
Previous topic
Vectors
Next topic
Geometric Objects
You are here
