Skip to content
Snippets Groups Projects
mat.rst 4.99 KiB

Matrices

The :mod:`~ost.geom` module defines matrices in two, three and four dimensions. All matrices store the values in row-major 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

2x2 real-valued matrix. The first signature creates a new identity matrix. The second signature initializes the matrix in row-major order.

3x3 real-valued matrix. The first signature creates a new identity matrix. The second signature initializes the matrix in row-major order.

4x4 real-valued matrix. The first signature creates a new identity matrix. The second signature initializes the matrix in row-major order.

Functions Operating on Matrices