topologicpy.Matrix module

class topologicpy.Matrix.Matrix

Bases: object

Methods

Add(matA, matB)

Adds the two input matrices.

ByCoordinateSystems(source, target[, ...])

Calculates the 4x4 transformation matrix that maps the source coordinate system to the target coordinate system.

ByScaling([scaleX, scaleY, scaleZ])

Creates a 4x4 scaling matrix.

ByTranslation([translateX, translateY, ...])

Creates a 4x4 translation matrix.

ByVectors(vectorA, vectorB[, orientationA, ...])

Creates a rotation matrix that aligns vectorA with vectorB and adjusts orientationA to match orientationB.

ByVectors_old(vectorB[, orientationA, ...])

Creates a rotation matrix that aligns vectorA with vectorB and adjusts orientationA to match orientationB.

Identity()

Creates a 4x4 identity translation matrix.

Invert(matA[, silent])

Inverts the input matrix.

Multiply(matA, matB)

Multiplies two matrices (matA and matB).

Subtract(matA, matB)

Subtracts the two input matrices.

Transpose(matrix)

Transposes the input matrix.

ByRotation

EigenvaluesAndVectors

static Add(matA, matB)

Adds the two input matrices.

Parameters
matAlist

The first input matrix.

matBlist

The second input matrix.

Returns
list

The matrix resulting from the addition of the two input matrices.

static ByCoordinateSystems(source, target, mantissa: int = 6, silent: bool = False)

Calculates the 4x4 transformation matrix that maps the source coordinate system to the target coordinate system. An example of a coordinate system matrix is: source = [ [0, 0, 0], # Origin [1, 0, 0], # X-axis [0, 1, 0], # Y-axis [0, 0, 1] # Z-axis ]

Parameters
sourcelist

The 4X3 matrix representing source coordinate system. The rows are in the order: Origin, X-Axis, Y-Axis, Z-Axis.

targetlist

The 4X3 matrix representing target coordinate system. The rows are in the order: Origin, X-Axis, Y-Axis, Z-Axis.

mantissaint , optional

The number of decimal places to round the result to. Default is 6.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list

The 4x4 transformation matrix.

static ByRotation(angleX=0, angleY=0, angleZ=0, order='xyz')
static ByScaling(scaleX=1.0, scaleY=1.0, scaleZ=1.0)

Creates a 4x4 scaling matrix.

Parameters
scaleXfloat , optional

The desired scaling factor along the X axis. Default is 1.

scaleYfloat , optional

The desired scaling factor along the X axis. Default is 1.

scaleZfloat , optional

The desired scaling factor along the X axis. Default is 1.

Returns
list

The created 4X4 scaling matrix.

static ByTranslation(translateX=0, translateY=0, translateZ=0)

Creates a 4x4 translation matrix.

Parameters
translateXfloat , optional

The desired translation distance along the X axis. Default is 0.

translateYfloat , optional

The desired translation distance along the X axis. Default is 0.

translateZfloat , optional

The desired translation distance along the X axis. Default is 0.

Returns
list

The created 4X4 translation matrix.

static ByVectors(vectorA: list, vectorB: list, orientationA: list = [1, 0, 0], orientationB: list = [1, 0, 0])

Creates a rotation matrix that aligns vectorA with vectorB and adjusts orientationA to match orientationB.

Parameters
vectorAlist

The first input vector.

vectorBlist

The second input vector to align with.

orientationAlist

The orientation vector associated with vectorA.

orientationBlist

The orientation vector associated with vectorB.

Returns
list

The 4x4 transformation matrix.

ByVectors_old(vectorB: list, orientationA: list = [1, 0, 0], orientationB: list = [1, 0, 0])

Creates a rotation matrix that aligns vectorA with vectorB and adjusts orientationA to match orientationB.

Parameters
vectorAlist

The first input vector.

vectorBlist

The second input vector to align with.

orientationAlist

The orientation vector associated with vectorA.

orientationBlist

The orientation vector associated with vectorB.

Returns
list

The 4x4 transformation matrix.

static EigenvaluesAndVectors(matrix, mantissa: int = 6, silent: bool = False)
static Identity()

Creates a 4x4 identity translation matrix.

Parameters
Returns
list

The created 4X4 identity matrix.

static Invert(matA, silent: bool = False)

Inverts the input matrix.

Parameters
matAlist of list of float

The input matrix.

silentbool , optional

If set to True, error and warning messages are suppressed. Default is False.

Returns
list of list of float

The resulting matrix after it has been inverted.

static Multiply(matA, matB)

Multiplies two matrices (matA and matB). The first matrix (matA) is applied first in the transformation, followed by the second matrix (matB).

Parameters
matAlist of list of float

The first input matrix.

matBlist of list of float

The second input matrix.

Returns
list of list of float

The resulting matrix after multiplication.

static Subtract(matA, matB)

Subtracts the two input matrices.

Parameters
matAlist

The first input matrix.

matBlist

The second input matrix.

Returns
list

The matrix resulting from the subtraction of the second input matrix from the first input matrix.

static Transpose(matrix)

Transposes the input matrix.

Parameters
matrixlist

The input matrix.

Returns
list

The transposed matrix.