Matrix44 (hwx.common.math)#
- class Matrix44(values=None, origin=None, angles=None, degrees=False, scale=None, xv=None, yv=None, zv=None, xvyv=None, xvzv=None, yvxv=None, yvzv=None, zvxv=None, zvyv=None, xp=None, yp=None, zp=None, xpyp=None, xpzp=None, ypxp=None, ypzp=None, zpxp=None, zpyp=None, eulerParameters=None)#
Bases:
list
A 4x4 orthonormal Matrix.
# Name
Type
property
property
property
property
property
property
# Name
Description
copy
(self)Creates a copy of self.
divide
(self, other)Returns the result of the multiplication with the inverse of other.
format
(self, format=’%s’)Formats as a string.
getAxisAndAngleOfRotation
(self)Returns the axis and angle from the rotation matrix
getDeterminant
(self)Returns the matrix determinant.
getEulerAngles
(self, degrees=False)Returns the Euler angles.
getTrace
(self)getTranslation
(self)Returns the position as a Point.
invert
(self)Computes the inverse.
isIdentity
(self)Returns True if self is the identity matrix, False otherwise.
multiply
(self, other)Multiplies with other.
multiplyPoint
(self, x, y=None, z=None)Multiplies with a Point.
multiplyVector
(self, x, y=None, z=None)Multiplies with the Vector specified with x, y, z.
orientFromAxes
(self, axes, dir1, dir2=(1, 0, 0))Orients with the specified axes.
orientFromEulerAngles
(self, e1, e2=None, e3=None, degrees=False)Orients with the specified Euler angles.
orientFromEulerParameters
(self, e0, e1=None, e2=None, e3=None)Orients with the specified Euler parameters.
orthogonalize
(self)Orthogonalizes the axes (x, y, z).
multiplyPoint
(self, x, y=None, z=None)Multiplies with a Point.
pts
(self, pts)Returns the result of multiplying each Point in the specified list of
rotate
(self, axis, angle, degrees=True)Rotates around the specified axis.
rotateAroundAxis
(self, axis, angle, degrees=True)Rotates around the axis.
rotx
(self, angle, degrees=True)Rotates around the x-axis.
roty
(self, angle, degrees=True)Rotates around the y-axis.
rotz
(self, angle, degrees=True)Rotates around the z-axis.
scale
(self, x, y=None, z=None)Scales by the specified amount in x, y, z.
setTranslation
(self, x, y=None, z=None)Sets the position as a Point.
translate
(self, x=0, y=None, z=None)Translates by the specified distance each x, y, z vector.
transpose
(self)Returns the transpose.
update
(self, other)Copies the data from other to self.
multiplyVector
(self, x, y=None, z=None)Multiplies with the Vector specified with x, y, z.
zeroSmallValues
(self, zero=1e-10)Sets all components that are less than the specified value to zero.
Example
from hwx.common.math import Matrix44 # Constructor using values mtx = Matrix44( values=( [1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0], [0.29283, 1.04139, 0.95395, 1] ) ) print(mtx.format("%.2f")) print("Location of the matrix as a point is {}, which is equal to the origin {}".format( mtx.location, mtx.origin)) # Constructor using location and angles mtx = Matrix44( origin=[1, 2, 3], angles=(90, 0, 0), degrees=True ) print(mtx) print("The orientation of the matrix is given by the Euler Angles in radians {}".format( mtx.angles)) print("A vector along the x axis {}".format(mtx.x)) print("A vector along the y axis {}".format(mtx.y)) print("A vector along the z axis {}".format(mtx.z))
- update(other)#
Copies the data from other to self.
- orthogonalize()#
Orthogonalizes the axes (x, y, z).
- Raises:
RuntimeError – If Matrix44 can not be orthogonalized.
- Returns:
A Matrix44 with x, y, z being orthogonal.
- Return type:
- format(format='%s')#
Formats as a string.
- Parameters:
format (str) – The format style to use.
- Returns:
A string represantation of the instance Matrix44 object on which it was called.
- Return type:
str
- isIdentity()#
Returns True if self is the identity matrix, False otherwise.
- property angles#
The Euler angles (Body313) in radians.
- orientFromEulerAngles(e1, e2=None, e3=None, degrees=False)#
Orients with the specified Euler angles.
- Parameters:
e1 (float) – Rotation around x-axis.
e2 (float) – Rotation around y-axis.
e3 (float) – Rotation around z-axis.
degrees (bool) – Determines if the angle values are in degrees or not.
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- getEulerAngles(degrees=False)#
Returns the Euler angles.
- Parameters:
degrees (bool) – Determines if the angle values are in degrees or not.
- Returns:
The Euler angles.
- Return type:
list
- orientFromEulerParameters(e0, e1=None, e2=None, e3=None)#
Orients with the specified Euler parameters.
- Parameters:
e0 (float) – Euler parameter.
e1 (float) – Euler parameter.
e2 (float) – Euler parameter.
e3 (float) – Euler parameter.
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- orientFromAxes(axes, dir1, dir2=(1, 0, 0))#
Orients with the specified axes.
- Parameters:
- Raises:
RuntimeError – In case of unsupported axes specification
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- property location#
Returns or sets the location/origin value.
- property origin#
Returns or sets the location/origin value.
- translate(x=0, y=None, z=None)#
Translates by the specified distance each x, y, z vector.
If y is None, x is assumed to be a list of 3 floats.
- Parameters:
x (float) – The distance to translate the ‘x’ vector.
y (float) – The distance to translate the ‘y’ vector.
z (float) – The distance to translate the ‘z’ vector.
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- setTranslation(x, y=None, z=None)#
Sets the position as a Point.
If y is None, x is assumed to be a list of 3 floats.
- Parameters:
x (float) – The vector to set the ‘x’ vector.
y (float) – The vector to set the ‘y’ vector.
z (float) – The vector to set the ‘z’ vector.
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- getTranslation()#
Returns the position as a Point.
- scale(x, y=None, z=None)#
Scales by the specified amount in x, y, z.
If y is None, x is assumed to be a list of 3 floats.
- Parameters:
x (float) – The factor to multiply the ‘x’ vector with.
y (float) – The factor to multiply the ‘y’ vector with.
z (float) – The factor to multiply the ‘z’ vector with.
- Returns:
A newly created Matrix44.
- Return type:
- rotate(axis, angle, degrees=True)#
Rotates around the specified axis.
This is a body rotation.
- rotx(angle, degrees=True)#
Rotates around the x-axis.
This is a body rotation.
- Parameters:
angle (float) – The rotation angle.
degrees (bool) – Determines if angles is in degrees or not.
- Returns:
A newly created Matrix44.
- Return type:
- roty(angle, degrees=True)#
Rotates around the y-axis.
This is a body rotation.
- Parameters:
angle (float) – The rotation angle.
degrees (bool) – Determines if angles is in degrees or not.
- Returns:
A newly created Matrix44.
- Return type:
- rotz(angle, degrees=True)#
Rotates around the z-axis.
This is a body rotation.
- Parameters:
angle (float) – The rotation angle.
degrees (bool) – Determines if angles is in degrees or not.
- Returns:
A newly created Matrix44.
- Return type:
- rotateAroundAxis(axis, angle, degrees=True)#
Rotates around the axis.
This is a body rotation.
- transpose()#
Returns the transpose.
- multiply(other)#
Multiplies with other.
- divide(other)#
Returns the result of the multiplication with the inverse of other.
- invert()#
Computes the inverse.
- Returns:
The inverse of the instance Matrix44 object on which it was called.
- Return type:
- getDeterminant()#
Returns the matrix determinant.
- getAxisAndAngleOfRotation()#
Returns the axis and angle from the rotation matrix
- zeroSmallValues(zero=1e-10)#
Sets all components that are less than the specified value to zero.
- Parameters:
zero (float) – The tolerance on what to zero.
- Returns:
A reference to the instance Matrix44 object on which it was called.
- Return type:
- multiplyPoint(x, y=None, z=None)#
Multiplies with a Point.
Points are represented as mathematical column points and have a one in the fourth position, which includes translation operations.
- pt(x, y=None, z=None)#
Multiplies with a Point.
Points are represented as mathematical column points and have a one in the fourth position, which includes translation operations.
- pts(pts)#
Returns the result of multiplying each Point in the specified list of Points with self.
- multiplyVector(x, y=None, z=None)#
Multiplies with the Vector specified with x, y, z.
Vectors are represented as mathematical column vectors and have a zero in the fourth position, which does not include translation operations.
- vec(x, y=None, z=None)#
Multiplies with the Vector specified with x, y, z.
Vectors are represented as mathematical column vectors and have a zero in the fourth position, which does not include translation operations.
- property x#
The vector along the x-axis.
- property y#
The vector along the y-axis.
- property z#
The vector along the z-axis.
- zp(pt1, pt2=None)#
Depricated