Uranium
Application Framework
UM.Math.Matrix.Matrix Class Reference

This class is a 4x4 homogeneous matrix wrapper around numpy. More...

Public Member Functions

def LOG_NUMPY (self, str_matrix_name, matrix)
 
def LOG_MATRIX (self, str_matrix_name, matrix)
 
def __init__ (self, data=None)
 
def __eq__ (self, other)
 
def at (self, int x, int y)
 
def setRow (self, int index, value)
 
def setColumn (self, int index, value)
 
def multiply (self, Union[Vector, "Matrix"] other, bool copy=False)
 
def preMultiply (self, Union[Vector, "Matrix"] other, bool copy=False)
 
def getData (self)
 Get raw data. More...
 
def setToIdentity (self)
 Create a 4x4 identity matrix. More...
 
def invert (self)
 Invert the matrix.
 
"Matrix" getInverse (self)
 Return a inverted copy of the matrix. More...
 
"Matrix" getTransposed (self)
 Return the transpose of the matrix. More...
 
def translate (self, Vector direction)
 Translate the matrix based on Vector. More...
 
def setByTranslation (self, Vector direction)
 Set the matrix by translation vector. More...
 
def setTranslation (self, translation)
 
Vector getTranslation (self)
 
def rotateByAxis (self, angle, Vector direction, Optional[Vector] point=None)
 Rotate the matrix based on rotation axis. More...
 
def setByRotationAxis (self, angle, Vector direction, Optional[Vector] point=None)
 Set the matrix based on rotation axis. More...
 
def compose (self, Vector scale=None, Vector shear=None, Vector angles=None, Vector translate=None, perspective=None, Vector mirror=None)
 Return transformation matrix from sequence of transformations. More...
 
def getEuler (self, axes="sxyz")
 Return Euler angles from rotation matrix for specified axis sequence. More...
 
def setByEuler (self, ai, aj, ak, axes="sxyz")
 Return homogeneous rotation matrix from Euler angles and axis sequence. More...
 
def scaleByFactor (self, factor, Optional[Vector] origin=None, Optional[Vector] direction=None)
 Scale the matrix by factor wrt origin & direction. More...
 
def setByScaleFactor (self, factor, Optional[Vector] origin=None, Optional[Vector] direction=None)
 Set the matrix by scale by factor wrt origin & direction. More...
 
def setByScaleVector (self, Vector scale)
 
Vector getScale (self)
 
def setOrtho (self, left, right, bottom, top, near, far)
 Set the matrix to an orthographic projection. More...
 
def setPerspective (self, fovy, aspect, near, far)
 Set the matrix to a perspective projection. More...
 
def decompose (self)
 Return sequence of transformations from transformation matrix. More...
 
def __repr__ (self)
 

Static Public Member Functions

"Matrix" fromPositionOrientationScale (Vector position, "Quaternion" orientation, Vector scale)
 

Detailed Description

This class is a 4x4 homogeneous matrix wrapper around numpy.

Heavily based (in most cases a straight copy with some refactoring) on the excellent 'library' Transformations.py created by Christoph Gohlke.

Member Function Documentation

◆ compose()

def UM.Math.Matrix.Matrix.compose (   self,
Vector   scale = None,
Vector   shear = None,
Vector   angles = None,
Vector   translate = None,
  perspective = None,
Vector   mirror = None 
)

Return transformation matrix from sequence of transformations.

This is the inverse of the decompose_matrix function.

Parameters
scale: vector of 3 scaling factors
shear: list of shear factors for x-y, x-z, y-z axes
angles: list of Euler angles about static x, y, z axes
translate: translation vector along x, y, z axes
perspective: perspective partition of matrix
mirrorvector with mirror factors (1 if that axis is not mirrored, -1 if it is)

◆ decompose()

def UM.Math.Matrix.Matrix.decompose (   self)

Return sequence of transformations from transformation matrix.

Returns
Tuple containing scale (vector), shear (vector), angles (vector) and translation (vector) It will raise a ValueError if matrix is of wrong type or degenerative.

◆ getData()

def UM.Math.Matrix.Matrix.getData (   self)

Get raw data.

Returns
4x4 numpy array

◆ getEuler()

def UM.Math.Matrix.Matrix.getEuler (   self,
  axes = "sxyz" 
)

Return Euler angles from rotation matrix for specified axis sequence.

axes : One of 24 axis sequences as string or encoded tuple Note that many Euler angle triplets can describe one matrix.

◆ getInverse()

"Matrix" UM.Math.Matrix.Matrix.getInverse (   self)

Return a inverted copy of the matrix.

Returns
The invertex matrix.

◆ getTransposed()

"Matrix" UM.Math.Matrix.Matrix.getTransposed (   self)

Return the transpose of the matrix.

◆ rotateByAxis()

def UM.Math.Matrix.Matrix.rotateByAxis (   self,
  angle,
Vector  direction,
Optional[Vector]   point = None 
)

Rotate the matrix based on rotation axis.

Parameters
angleThe angle by which matrix needs to be rotated.
directionAxis by which the matrix needs to be rotated about.
pointPoint where from where the rotation happens. If None, origin is used.

◆ scaleByFactor()

def UM.Math.Matrix.Matrix.scaleByFactor (   self,
  factor,
Optional[Vector]   origin = None,
Optional[Vector]   direction = None 
)

Scale the matrix by factor wrt origin & direction.

Parameters
factorThe factor by which to scale
originFrom where does the scaling need to be done
directionIn what direction is the scaling (if None, it's uniform)

◆ setByEuler()

def UM.Math.Matrix.Matrix.setByEuler (   self,
  ai,
  aj,
  ak,
  axes = "sxyz" 
)

Return homogeneous rotation matrix from Euler angles and axis sequence.

Parameters
aiEulers roll
ajEulers pitch
akEulers yaw
axesOne of 24 axis sequences as string or encoded tuple

◆ setByRotationAxis()

def UM.Math.Matrix.Matrix.setByRotationAxis (   self,
  angle,
Vector  direction,
Optional[Vector]   point = None 
)

Set the matrix based on rotation axis.

This overwrites any existing data.

Parameters
angleThe angle by which matrix needs to be rotated in radians.
directionAxis by which the matrix needs to be rotated about.
pointPoint where from where the rotation happens. If None, origin is used.

◆ setByScaleFactor()

def UM.Math.Matrix.Matrix.setByScaleFactor (   self,
  factor,
Optional[Vector]   origin = None,
Optional[Vector]   direction = None 
)

Set the matrix by scale by factor wrt origin & direction.

This overwrites any existing data

Parameters
factorThe factor by which to scale
originFrom where does the scaling need to be done
directionIn what direction is the scaling (if None, it's uniform)

◆ setByTranslation()

def UM.Math.Matrix.Matrix.setByTranslation (   self,
Vector  direction 
)

Set the matrix by translation vector.

This overwrites any existing data.

Parameters
directionThe vector by which the (unit) matrix needs to be translated.

◆ setOrtho()

def UM.Math.Matrix.Matrix.setOrtho (   self,
  left,
  right,
  bottom,
  top,
  near,
  far 
)

Set the matrix to an orthographic projection.

This overwrites any existing data.

Parameters
leftThe left edge of the projection
rightThe right edge of the projection
topThe top edge of the projection
bottomThe bottom edge of the projection
nearThe near plane of the projection
farThe far plane of the projection

◆ setPerspective()

def UM.Math.Matrix.Matrix.setPerspective (   self,
  fovy,
  aspect,
  near,
  far 
)

Set the matrix to a perspective projection.

This overwrites any existing data.

Parameters
fovyField of view in the Y direction
aspectThe aspect ratio
nearDistance to the near plane
farDistance to the far plane

◆ setToIdentity()

def UM.Math.Matrix.Matrix.setToIdentity (   self)

Create a 4x4 identity matrix.

This overwrites any existing data.

◆ translate()

def UM.Math.Matrix.Matrix.translate (   self,
Vector  direction 
)

Translate the matrix based on Vector.

Parameters
directionThe vector by which the matrix needs to be translated.

The documentation for this class was generated from the following file: