geometry – Geometry and algebra

class Matrix(rows)

Mathematical representation of a matrix. It supports common operations such as matrix addition (+), subtraction (-), and multiplication (*). A Matrix object is immutable.

Parameters:rows (list) – List of rows. Each row is itself a list of numbers.

Returns a new Matrix that is the transpose of the original.


Returns a tuple (m, n), where m is the number of rows and n is the number of columns.

vector(x, y, z=None)

Convenience function to create a Matrix with the shape (3, 1) or (2, 1).

  • x (float) – x-coordinate of the vector.
  • y (float) – y-coordinate of the vector.
  • z (float) – z-coordinate of the vector (optional).

A matrix with the shape of a column vector.

Return type: