Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.Matrix3 class

2D float transformation matrix

Static methods

def translation(arg0: Vector2, /) -> Matrix3
2D translation matrix
def from(rotation_scaling: Matrix2x2, translation: Vector2) -> Matrix3
Create a matrix from a rotation/scaling part and a translation part
def from_diagonal(arg0: Vector3, /) -> Matrix3
Construct a diagonal matrix
def identity_init(value: float = 1.0) -> Matrix3
Construct an identity matrix
def projection(size: Vector2) -> Matrix3
2D projection matrix
def reflection(arg0: Vector2, /) -> Matrix3
2D reflection matrix
def rotation(arg0: Rad, /) -> Matrix3
2D rotation matrix
def scaling(arg0: Vector2, /) -> Matrix3
2D scaling matrix
def shearing_x(amount: float) -> Matrix3
2D shearing matrix along the X axis
def shearing_y(amount: float) -> Matrix3
2D shearning matrix along the Y axis
def zero_init() -> Matrix3
Construct a zero-filled matrix

Methods

def determinant(self, /) -> float
Determinant
def diagonal(self, /) -> Vector3
Values on diagonal
def flipped_cols(self, /) -> Matrix3
Matrix with flipped cols
def flipped_rows(self, /) -> Matrix3
Matrix with flipped rows
def inverted(self, /) -> Matrix3
Inverted matrix
def inverted_orthogonal(self, /) -> Matrix3
Inverted orthogonal matrix
def inverted_rigid(self, /) -> Matrix3
Inverted rigid transformation matrix
def is_orthogonal(self, /) -> bool
Whether the matrix is orthogonal
def is_rigid_transformation(self, /) -> bool
Check whether the matrix represents a rigid transformation
def rotation(self, /) -> Matrix2x2
2D rotation part of the matrix
def rotation_normalized(self, /) -> Matrix2x2
2D rotation part of the matrix assuming there is no scaling
def rotation_scaling(self, /) -> Matrix2x2
2D rotation and scaling part of the matrix
def rotation_shear(self, /) -> Matrix2x2
2D rotation and shear part of the matrix
def scaling(self, /) -> Vector2
Non-uniform scaling part of the matrix
def scaling_squared(self, /) -> Vector2
Non-uniform scaling part of the matrix, squared
def trace(self, /) -> float
Trace of the matrix
def transform_point(self, arg0: Vector2, /) -> Vector2
Transform a 2D point with the matrix
def transform_vector(self, arg0: Vector2, /) -> Vector2
Transform a 2D vector with the matrix
def transposed(self, /) -> Matrix3
Transposed matrix
def uniform_scaling(self, /) -> float
Uniform scaling part of the matrix
def uniform_scaling_squared(self, /) -> float
Uniform scaling part of the matrix, squared

Special methods

def __add__(self, arg0: Matrix3, /) -> Matrix3
Add a matrix
def __eq__(self, arg0: Matrix3x3, /) -> bool
Equality comparison
def __getitem__(self, arg0: int, /) -> Vector3
Column at given position
def __getitem__(self, arg0: typing.Tuple[int, int], /) -> float
Value at given col/row
def __iadd__(self, arg0: Matrix3, /) -> Matrix3
Add and assign a matrix
def __imul__(self, arg0: float, /) -> Matrix3
Multiply with a scalar and assign
def __init__(self, arg0: Matrix3d, /) -> None
Construct from different underlying type
def __init__(self, arg0: buffer, /) -> None
Construct from a buffer
def __init__(self, /) -> None
Default constructor
def __init__(self, arg0: float, /) -> None
Construct a matrix with one value for all components
def __init__(self, arg0: Vector3, arg1: Vector3, arg2: Vector3, /) -> None
Construct from column vectors
def __init__(self, arg0: typing.Tuple[Vector3, Vector3, Vector3], /) -> None
Construct from a column vector tuple
def __init__(self, arg0: typing.Tuple[typing.Tuple[float, float, float], typing.Tuple[float, float, float], typing.Tuple[float, float, float]], /) -> None
Construct from a column tuple
def __isub__(self, arg0: Matrix3, /) -> Matrix3
Subtract and assign a matrix
def __itruediv__(self, arg0: float, /) -> Matrix3
Divide with a scalar and assign
def __len__() -> int
Matrix column count. Returns 3.
def __matmul__(self, arg0: Matrix3, /) -> Matrix3
Multiply a matrix
def __mul__(self, arg0: float, /) -> Matrix3
Multiply with a scalar
def __mul__(self, arg0: Vector3, /) -> Vector3
Multiply a vector
def __ne__(self, arg0: Matrix3x3, /) -> bool
Non-equality comparison
def __neg__(self, /) -> Matrix3
Negated matrix
def __repr__(self, /) -> str
Object representation
def __rmul__(self, arg0: float, /) -> Matrix3
Multiply a scalar with a matrix
def __rtruediv__(self, arg0: float, /) -> Matrix3
Divide a matrix with a scalar and invert
def __setitem__(self, arg0: int, arg1: Vector3, /) -> None
Set a column at given position
def __setitem__(self, arg0: typing.Tuple[int, int], arg1: float, /) -> None
Set a value at given col/row
def __sub__(self, arg0: Matrix3, /) -> Matrix3
Subtract a matrix
def __truediv__(self, arg0: float, /) -> Matrix3
Divide with a scalar

Properties

Right-pointing 2D vector
translation: Vector2 get set
2D translation part of the matrix
up: Vector2 get set
Up-pointing 2D vector