Matrix44 (hwx.common.math)¶
A 4x4 orthonormal Matrix.
Public Methods¶
copy (self) divide (self, other) format (self, format=’%s’) getDeterminant (self) getEulerAngles (self, degrees=False) getTranslation (self) invert (self) isIdentity (self) multiply (self, other) multiplyPoint (self, x, y=None, z=None) multiplyVector (self, x, y=None, z=None) orientFromAxes (self, axes, dir1, dir2=(1, 0, 0)) orientFromEulerAngles (self, e1, e2=None, e3=None, degrees=False) orientFromEulerParameters (self, e0, e1=None, e2=None, e3=None) orthogonalize (self) pt (self, x, y=None, z=None) pts (self, pts) rotate (self, axis, angle, degrees=True) rotateAroundAxis (self, axis, angle, degrees=True) rotx (self, angle, degrees=True) roty (self, angle, degrees=True) rotz (self, angle, degrees=True) scale (self, x, y=None, z=None) setTranslation (self, x, y=None, z=None) translate (self, x=0, y=None, z=None) transpose (self) update (self, other) vec (self, x, y=None, z=None) zeroSmallValues (self, zero=1e-10) zp (self, pt1, pt2=None)
Property Details¶
-
angles
()
The Euler angles (Body313) in radians.
-
location
()
Returns or sets the location/origin value.
-
origin
()
Returns or sets the location/origin value.
-
x
()
The vector along the x-axis.
-
y
()
The vector along the y-axis.
-
z
()
The vector along the z-axis.
Method Details¶
-
copy
(self)
Creates a copy of self.
returns: | The newly created Matrix44. |
---|---|
rtype: | Matrix44 |
-
divide
(self, other)
Returns the result of the multiplication with the inverse of other.
param other: | The Matrix44 to inverse and multiply with. |
---|---|
type other: | Matrix44 |
returns: | The result of the multiplication with the inverse. |
rtype: | Matrix44 |
-
format
(self, format='%s')
Formats as a string.
param format: | The format style to use. |
---|---|
type format: | str |
returns: | A string represantation of the instance Matrix44 object on which it was called. |
rtype: | str |
-
getDeterminant
(self)¶
Returns the matrix determinant.
-
getEulerAngles
(self, degrees=False)¶
Returns the Euler angles.
param degrees: | Determines if the angle values are in degrees or not. |
---|---|
type degrees: | bool |
returns: | The Euler angles. |
rtype: | list |
-
getTranslation
(self)¶
Returns the position as a Point.
-
invert
(self)
Computes the inverse.
returns: | The inverse of the instance Matrix44 object on which it was called. |
---|---|
rtype: | Matrix44 |
-
isIdentity
(self)¶
Returns True if self is the identity matrix, False otherwise.
-
multiply
(self, other)
Multiplies with other.
param other: | The other to multiply with. |
---|---|
type other: | Union[int, float, Point, Vector, Matrix44] |
returns: | The result of the multiplication. |
rtype: | Union[Matrix44, Vector, Point] |
-
multiplyPoint
(self, 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.
param x: | An itetable of 3 or the x value of a Point. |
---|---|
type x: | Union[Point, list[float], float] |
param y: | The y value of a Point. |
type y: | float |
param z: | The z value of a Point. |
type z: | float |
returns: | The result of the multiplication. |
rtype: | Point |
-
multiplyVector
(self, x, y=None, z=None)¶
Multiplies with the Vector specified with x, y, z.
The x can be a float, Vector (or list).
Vectors are represented as mathematical column vectors and have a zero in the fourth position, which does not include translation operations.
param x: | An itetable of 3 or the x value of a Vector. |
---|---|
type x: | Union[Vector, list[float], float] |
param y: | The y value of a Vector. |
type y: | float |
param z: | The z value of a Vector. |
type z: | float |
returns: | The result of the multiplication. |
rtype: | Vector |
-
orientFromAxes
(self, axes, dir1, dir2=(1, 0, 0))¶
Orients with the specified axes.
param axes: | The axis to orient by: Valid choices are ‘x’, ‘y’, ‘z’, ‘xy’, ‘xz’, ‘yx’, ‘yz’, ‘zx’, ‘zy’. |
---|---|
type axes: | str |
param dir1: | The vector for the first axis. |
type dir1: | Union[Vector, list[float]] |
param dir2: | The vector for the second axis. |
type dir2: | Union[Vector, list[float]] |
raises: | RuntimeError – In case of unsupported axes specification |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
orientFromEulerAngles
(self, e1, e2=None, e3=None, degrees=False)¶
Orients with the specified Euler angles.
param e1: | Rotation around x-axis. |
---|---|
type e1: | float |
param e2: | Rotation around y-axis. |
type e2: | float |
param e3: | Rotation around z-axis. |
type e3: | float |
param degrees: | Determines if the angle values are in degrees or not. |
type degrees: | bool |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
orientFromEulerParameters
(self, e0, e1=None, e2=None, e3=None)¶
Orients with the specified Euler parameters.
param e0: | Euler parameter. |
---|---|
type e0: | float |
param e1: | Euler parameter. |
type e1: | float |
param e2: | Euler parameter. |
type e2: | float |
param e3: | Euler parameter. |
type e3: | float |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
orthogonalize
(self)
Orthogonalizes the axes (x, y, z).
raises: | RuntimeError – If Matrix44 can not be orthogonalized. |
---|---|
returns: | A Matrix44 with x, y, z being orthogonal. |
rtype: | Matrix44 |
-
pt
(self, 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.
param x: | An itetable of 3 or the x value of a Point. |
---|---|
type x: | Union[Point, list[float], float] |
param y: | The y value of a Point. |
type y: | float |
param z: | The z value of a Point. |
type z: | float |
returns: | The result of the multiplication. |
rtype: | Point |
-
pts
(self, pts)
Returns the result of multiplying each Point in the specified list of Points with self.
param pts: | A Point (or list). |
---|---|
type pts: | list[Union[Point, list[float]]] |
returns: | The result of the pieswise multiplication. |
rtype: | list[Point] |
-
rotate
(self, axis, angle, degrees=True)
Rotates around the specified axis.
This is a body rotation.
param axis: | The rotation axis. Valid choices are “x”, “y”, “z” or any Vector. |
---|---|
type axis: | Union[Vector, str] |
param angle: | The rotation angle. |
type angle: | float |
param degrees: | Determines if angles is in degrees or not. |
type degrees: | bool |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
rotateAroundAxis
(self, axis, angle, degrees=True)¶
Rotates around the axis.
This is a body rotation.
param axis: | The rotation axis. |
---|---|
type axis: | Vector |
param angle: | The rotation angle. |
type angle: | float |
param degrees: | Determines if angles is in degrees or not. |
type degrees: | bool |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
rotx
(self, angle, degrees=True)
Rotates around the x-axis.
This is a body rotation.
param angle: | The rotation angle. |
---|---|
type angle: | float |
param degrees: | Determines if angles is in degrees or not. |
type degrees: | bool |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
roty
(self, angle, degrees=True)
Rotates around the y-axis.
This is a body rotation.
param angle: | The rotation angle. |
---|---|
type angle: | float |
param degrees: | Determines if angles is in degrees or not. |
type degrees: | bool |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
rotz
(self, angle, degrees=True)
Rotates around the z-axis.
This is a body rotation.
param angle: | The rotation angle. |
---|---|
type angle: | float |
param degrees: | Determines if angles is in degrees or not. |
type degrees: | bool |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
scale
(self, 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.
param x: | The factor to multiply the ‘x’ vector with. |
---|---|
type x: | Union[float, list[float]] |
param y: | The factor to multiply the ‘y’ vector with. |
type y: | float |
param z: | The factor to multiply the ‘z’ vector with. |
type z: | float |
returns: | A newly created Matrix44. |
rtype: | Matrix44 |
-
setTranslation
(self, 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.
param x: | The vector to set the ‘x’ vector. |
---|---|
type x: | Union[float, list[float]] |
param y: | The vector to set the ‘y’ vector. |
type y: | float |
param z: | The vector to set the ‘z’ vector. |
type z: | float |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
translate
(self, 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.
param x: | The distance to translate the ‘x’ vector. |
---|---|
type x: | Union[float, list[float]] |
param y: | The distance to translate the ‘y’ vector. |
type y: | float |
param z: | The distance to translate the ‘z’ vector. |
type z: | float |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
transpose
(self)
Returns the transpose.
-
update
(self, other)
Copies the data from other to self.
param other: | The Matrix44 to copy values from. |
---|---|
type other: | Matrix44 |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
vec
(self, x, y=None, z=None)
Multiplies with the Vector specified with x, y, z.
The x can be a float, Vector (or list).
Vectors are represented as mathematical column vectors and have a zero in the fourth position, which does not include translation operations.
param x: | An itetable of 3 or the x value of a Vector. |
---|---|
type x: | Union[Vector, list[float], float] |
param y: | The y value of a Vector. |
type y: | float |
param z: | The z value of a Vector. |
type z: | float |
returns: | The result of the multiplication. |
rtype: | Vector |
-
zeroSmallValues
(self, zero=1e-10)¶
Sets all components that are less than the specified value to zero.
param zero: | The tolerance on what to zero. |
---|---|
type zero: | float |
returns: | A reference to the instance Matrix44 object on which it was called. |
rtype: | Matrix44 |
-
zp
(self, pt1, pt2=None)
Depricated