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.Matrix4d class

3D double transformation matrix

Static methods

def translation(arg0: Vector3d, /) -> Matrix4d
3D translation matrix
def from_(rotation_scaling: Matrix3x3d, translation: Vector3d) -> Matrix4d
Create a matrix from a rotation/scaling part and a translation part
def from_diagonal(arg0: Vector4d, /) -> Matrix4d
Construct a diagonal matrix
def identity_init(value: float = 1.0) -> Matrix4d
Construct an identity matrix
def look_at(eye: Vector3d, target: Vector3d, up: Vector3d) -> Matrix4d
Matrix oriented towards a specific point
def orthographic_projection(size: Vector2d, near: float, far: float) -> Matrix4d
3D orthographic projection matrix
def orthographic_projection(bottom_left: Vector2d, top_right: Vector2d, near: float, far: float) -> Matrix4d
3D off-center orthographic projection matrix
def perspective_projection(size: Vector2d, near: float, far: float) -> Matrix4d
3D perspective projection matrix
def perspective_projection(fov: Rad, aspect_ratio: float, near: float, far: float) -> Matrix4d
3D perspective projection matrix
def perspective_projection(bottom_left: Vector2d, top_right: Vector2d, near: float, far: float) -> Matrix4d
3D off-center perspective projection matrix
def reflection(arg0: Vector3d, /) -> Matrix4d
3D reflection matrix
def rotation(arg0: Rad, arg1: Vector3d, /) -> Matrix4d
3D rotation matrix
def rotation_x(arg0: Rad, /) -> Matrix4d
3D rotation matrix around the X axis
def rotation_y(arg0: Rad, /) -> Matrix4d
3D rotation matrix around the Y axis
def rotation_z(arg0: Rad, /) -> Matrix4d
3D rotation matrix around the Z axis
def scaling(arg0: Vector3d, /) -> Matrix4d
2D scaling matrix
def shearing_xy(amount_x: float, amount_y: float) -> Matrix4d
3D shearing matrix along the XY plane
def shearing_xz(amount_x: float, amount_z: float) -> Matrix4d
3D shearning matrix along the XZ plane
def shearing_yz(amount_y: float, amount_z: float) -> Matrix4d
3D shearing matrix along the YZ plane
def zero_init() -> Matrix4d
Construct a zero-filled matrix

Methods

def adjugate(self, /) -> Matrix4d
Adjugate matrix
def cofactor(self, col: int, row: int) -> float
Cofactor
def comatrix(self, /) -> Matrix4d
Matrix of cofactors
def determinant(self, /) -> float
Determinant
def diagonal(self, /) -> Vector4d
Values on diagonal
def flipped_cols(self, /) -> Matrix4d
Matrix with flipped cols
def flipped_rows(self, /) -> Matrix4d
Matrix with flipped rows
def inverted(self, /) -> Matrix4d
Inverted matrix
def inverted_orthogonal(self, /) -> Matrix4d
Inverted orthogonal matrix
def inverted_rigid(self, /) -> Matrix4d
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 normal_matrix(self, /) -> Matrix3x3d
Normal matrix
def rotation(self, /) -> Matrix3x3d
3D rotation part of the matrix
def rotation_normalized(self, /) -> Matrix3x3d
3D rotation part of the matrix assuming there is no scaling
def rotation_scaling(self, /) -> Matrix3x3d
3D rotation and scaling part of the matrix
def rotation_shear(self, /) -> Matrix3x3d
3D rotation and shear part of the matrix
def scaling(self, /) -> Vector3d
Non-uniform scaling part of the matrix
def scaling_squared(self, /) -> Vector3d
Non-uniform scaling part of the matrix, squared
def trace(self, /) -> float
Trace of the matrix
def transform_point(self, arg0: Vector3d, /) -> Vector3d
Transform a 3D point with the matrix
def transform_vector(self, arg0: Vector3d, /) -> Vector3d
Transform a 3D vector with the matrix
def transposed(self, /) -> Matrix4d
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: Matrix4d, /) -> Matrix4d
Add a matrix
def __eq__(self, arg0: Matrix4x4d, /) -> bool
Equality comparison
def __getitem__(self, arg0: int, /) -> Vector4d
Column at given position
def __getitem__(self, arg0: typing.Tuple[int, int], /) -> float
Value at given col/row
def __iadd__(self, arg0: Matrix4d, /) -> Matrix4d
Add and assign a matrix
def __imul__(self, arg0: float, /) -> Matrix4d
Multiply with a scalar and assign
def __init__(self, arg0: Matrix4, /) -> 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: Vector4d, arg1: Vector4d, arg2: Vector4d, arg3: Vector4d, /) -> None
Construct from column vectors
def __init__(self, arg0: typing.Tuple[Vector4d, Vector4d, Vector4d, Vector4d], /) -> None
Construct from a column vector tuple
def __init__(self, arg0: typing.Tuple[typing.Tuple[float, float, float, float], typing.Tuple[float, float, float, float], typing.Tuple[float, float, float, float], typing.Tuple[float, float, float, float]], /) -> None
Construct from a column tuple
def __isub__(self, arg0: Matrix4d, /) -> Matrix4d
Subtract and assign a matrix
def __itruediv__(self, arg0: float, /) -> Matrix4d
Divide with a scalar and assign
def __len__() -> int
Matrix column count. Returns 4.
def __matmul__(self, arg0: Matrix4d, /) -> Matrix4d
Multiply a matrix
def __mul__(self, arg0: float, /) -> Matrix4d
Multiply with a scalar
def __mul__(self, arg0: Vector4d, /) -> Vector4d
Multiply a vector
def __ne__(self, arg0: Matrix4x4d, /) -> bool
Non-equality comparison
def __neg__(self, /) -> Matrix4d
Negated matrix
def __repr__(self, /) -> str
Object representation
def __rmul__(self, arg0: float, /) -> Matrix4d
Multiply a scalar with a matrix
def __rtruediv__(self, arg0: float, /) -> Matrix4d
Divide a matrix with a scalar and invert
def __setitem__(self, arg0: int, arg1: Vector4d, /) -> 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: Matrix4d, /) -> Matrix4d
Subtract a matrix
def __truediv__(self, arg0: float, /) -> Matrix4d
Divide with a scalar

Properties

backward: Vector3d get set
Backward-pointing 3D vector
Right-pointing 3D vector
translation: Vector3d get set
3D translation part of the matrix
up: Vector3d get set
Up-pointing 3D vector