Uranium
Application Framework
|
This class is a 4x4 homogeneous matrix wrapper around numpy. More...
Public Member Functions | |
LOG_NUMPY (self, str_matrix_name, matrix) | |
LOG_MATRIX (self, str_matrix_name, matrix) | |
__init__ (self, data=None) | |
__eq__ (self, other) | |
at (self, int x, int y) | |
setRow (self, int index, value) | |
setColumn (self, int index, value) | |
multiply (self, Union[Vector, "Matrix"] other, bool copy=False) | |
preMultiply (self, Union[Vector, "Matrix"] other, bool copy=False) | |
getData (self) | |
Get raw data. | |
setToIdentity (self) | |
Create a 4x4 identity matrix. | |
invert (self) | |
Invert the matrix. | |
"Matrix" | getInverse (self) |
Return a inverted copy of the matrix. | |
"Matrix" | getTransposed (self) |
Return the transpose of the matrix. | |
translate (self, Vector direction) | |
Translate the matrix based on Vector. | |
setByTranslation (self, Vector direction) | |
Set the matrix by translation vector. | |
setTranslation (self, translation) | |
Vector | getTranslation (self) |
rotateByAxis (self, angle, Vector direction, Optional[Vector] point=None) | |
Rotate the matrix based on rotation axis. | |
setByRotationAxis (self, angle, Vector direction, Optional[Vector] point=None) | |
Set the matrix based on rotation axis. | |
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. | |
getEuler (self, axes="sxyz") | |
Return Euler angles from rotation matrix for specified axis sequence. | |
setByEuler (self, ai, aj, ak, axes="sxyz") | |
Return homogeneous rotation matrix from Euler angles and axis sequence. | |
scaleByFactor (self, factor, Optional[Vector] origin=None, Optional[Vector] direction=None) | |
Scale the matrix by factor wrt origin & direction. | |
setByScaleFactor (self, factor, Optional[Vector] origin=None, Optional[Vector] direction=None) | |
Set the matrix by scale by factor wrt origin & direction. | |
setByScaleVector (self, Vector scale) | |
Vector | getScale (self) |
setOrtho (self, left, right, bottom, top, near, far) | |
Set the matrix to an orthographic projection. | |
setPerspective (self, fovy, aspect, near, far) | |
Set the matrix to a perspective projection. | |
decompose (self) | |
Return sequence of transformations from transformation matrix. | |
__repr__ (self) | |
Static Public Member Functions | |
"Matrix" | fromPositionOrientationScale (Vector position, "Quaternion" orientation, Vector scale) |
Protected Member Functions | |
_unitVector (self, data, axis=None, out=None) | |
Protected Attributes | |
_data | |
Static Protected Attributes | |
float | _EPS = numpy.finfo(float).eps * 4.0 |
dict | _AXES2TUPLE |
list | _NEXT_AXIS = [1, 2, 0, 1] |
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.
|
protected |
Return ndarray normalized by length, i.e. Euclidean norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, axis=-1) >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=2)), 2) >>> numpy.allclose(v1, v2) True >>> v1 = unit_vector(v0, axis=1) >>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=1)), 1) >>> numpy.allclose(v1, v2) True >>> v1 = numpy.empty((5, 4, 3)) >>> unit_vector(v0, axis=1, out=v1) >>> numpy.allclose(v1, v2) True >>> list(unit_vector([])) [] >>> list(unit_vector([1])) [1.0]
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.
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 |
mirror | vector with mirror factors (1 if that axis is not mirrored, -1 if it is) |
UM.Math.Matrix.Matrix.decompose | ( | self | ) |
Return sequence of transformations from transformation matrix.
UM.Math.Matrix.Matrix.getData | ( | self | ) |
Get raw data.
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.
"Matrix" UM.Math.Matrix.Matrix.getInverse | ( | self | ) |
Return a inverted copy of the matrix.
Rotate the matrix based on rotation axis.
angle | The angle by which matrix needs to be rotated. |
direction | Axis by which the matrix needs to be rotated about. |
point | Point where from where the rotation happens. If None, origin is used. |
UM.Math.Matrix.Matrix.scaleByFactor | ( | self, | |
factor, | |||
Optional[Vector] | origin = None , |
||
Optional[Vector] | direction = None |
||
) |
Scale the matrix by factor wrt origin & direction.
factor | The factor by which to scale |
origin | From where does the scaling need to be done |
direction | In what direction is the scaling (if None, it's uniform) |
UM.Math.Matrix.Matrix.setByEuler | ( | self, | |
ai, | |||
aj, | |||
ak, | |||
axes = "sxyz" |
|||
) |
Return homogeneous rotation matrix from Euler angles and axis sequence.
ai | Eulers roll |
aj | Eulers pitch |
ak | Eulers yaw |
axes | One of 24 axis sequences as string or encoded tuple |
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.
angle | The angle by which matrix needs to be rotated in radians. |
direction | Axis by which the matrix needs to be rotated about. |
point | Point where from where the rotation happens. If None, origin is used. |
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
factor | The factor by which to scale |
origin | From where does the scaling need to be done |
direction | In what direction is the scaling (if None, it's uniform) |
UM.Math.Matrix.Matrix.setByTranslation | ( | self, | |
Vector | direction | ||
) |
Set the matrix by translation vector.
This overwrites any existing data.
direction | The vector by which the (unit) matrix needs to be translated. |
UM.Math.Matrix.Matrix.setOrtho | ( | self, | |
left, | |||
right, | |||
bottom, | |||
top, | |||
near, | |||
far | |||
) |
Set the matrix to an orthographic projection.
This overwrites any existing data.
left | The left edge of the projection |
right | The right edge of the projection |
top | The top edge of the projection |
bottom | The bottom edge of the projection |
near | The near plane of the projection |
far | The far plane of the projection |
UM.Math.Matrix.Matrix.setPerspective | ( | self, | |
fovy, | |||
aspect, | |||
near, | |||
far | |||
) |
Set the matrix to a perspective projection.
This overwrites any existing data.
fovy | Field of view in the Y direction |
aspect | The aspect ratio |
near | Distance to the near plane |
far | Distance to the far plane |
UM.Math.Matrix.Matrix.setToIdentity | ( | self | ) |
Create a 4x4 identity matrix.
This overwrites any existing data.
UM.Math.Matrix.Matrix.translate | ( | self, | |
Vector | direction | ||
) |
Translate the matrix based on Vector.
direction | The vector by which the matrix needs to be translated. |
|
staticprotected |