![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
A 4x4 matrix class.
Enumeration of the components raw data index. The components can be accessed by using the [] operator.
Murl.Math.Matrix.XX | |
Murl.Math.Matrix.YX | |
Murl.Math.Matrix.ZX | |
Murl.Math.Matrix.WX | |
Murl.Math.Matrix.XY | |
Murl.Math.Matrix.YY | |
Murl.Math.Matrix.ZY | |
Murl.Math.Matrix.WY | |
Murl.Math.Matrix.XZ | |
Murl.Math.Matrix.YZ | |
Murl.Math.Matrix.ZZ | |
Murl.Math.Matrix.WZ | |
Murl.Math.Matrix.XW | |
Murl.Math.Matrix.YW | |
Murl.Math.Matrix.ZW | |
Murl.Math.Matrix.WW | |
Murl.Math.Matrix.NUM_COMPONENTS | The number of components. |
Enumeration of the components' bit masks
Murl.Math.Matrix.MASK_NONE | No component |
Murl.Math.Matrix.MASK_XX | XX component mask |
Murl.Math.Matrix.MASK_YX | YX component mask |
Murl.Math.Matrix.MASK_ZX | ZX component mask |
Murl.Math.Matrix.MASK_WX | WX component mask |
Murl.Math.Matrix.MASK_XY | XY component mask |
Murl.Math.Matrix.MASK_YY | YY component mask |
Murl.Math.Matrix.MASK_ZY | ZY component mask |
Murl.Math.Matrix.MASK_WY | WY component mask |
Murl.Math.Matrix.MASK_XZ | XZ component mask |
Murl.Math.Matrix.MASK_YZ | YZ component mask |
Murl.Math.Matrix.MASK_ZZ | ZZ component mask |
Murl.Math.Matrix.MASK_WZ | WZ component mask |
Murl.Math.Matrix.MASK_XW | XW component mask |
Murl.Math.Matrix.MASK_YW | YW component mask |
Murl.Math.Matrix.MASK_ZW | ZW component mask |
Murl.Math.Matrix.MASK_WW | WW component mask |
Murl.Math.Matrix.MASK_ALL | All components |
Enumeration of the predefined initialization types for constructing a Matrix(PredefinedType type).
Murl.Math.Matrix.UNINITIALIZED | Create an uninitialized instance. |
Murl.Math.Matrix.ZERO | Initialize with zero. |
Murl.Math.Matrix.IDENTITY | Initialize with the identity matrix. |
Enumeration of hint flags. Hints are used internally to optimize several operations.
Murl.Math.Matrix.FLAG_TRANSLATION | The matrix contains translation components. |
Murl.Math.Matrix.FLAG_ROTATION | The matrix contains rotation components. |
Murl.Math.Matrix.FLAG_SCALE | The matrix contains scale components. |
Murl.Math.Matrix.FLAG_ARBITRARY | The matrix contains arbitrary components. |
Murl.Math.Matrix.FLAG_NO_HINTS | The matrix has no component hints. |
The default constructor, creating an identity matrix. Hints are disabled by default.
Murl.Math.Matrix new()
Constructor to create a matrix from a predefined type. Hints are disabled by default.
Murl.Math.Matrix new(Murl.Math.Matrix.PredefinedType type)
type | The predefined type. |
Create a look-at matrix from a given center point, target point and up vector.
Murl.Math.Matrix LookAt(Murl.Math.Vector center, Murl.Math.Vector target, Murl.Math.Vector up)
center | The center point position vector. |
target | The target point position vector. |
up | The up direction vector. |
Get the hint flags.
Integer GetHints()
Set the hint flags.
SetHints(Integer mask)
mask | The bit-mask of hints to set. |
Clear hint flags.
ClearHints(Integer mask)
mask | The bit-mask of hints to clear. |
Enable hints. Enabling hints requires good knowlede of the entire Matrix class e.g. several setter methods do not consider hints.
EnableHints(Boolean autoDetect)
autoDetect | Evaluate the correct hints if true. |
Disable hints.
DisableHints()
Clear all components of the matrix instance. Set the component data array to zero.
Clear()
Load the identity matrix to the current instance.
SetIdentity()
Load the identity matrix to the upper 3x3 matrix
SetIdentityRotation()
Copy the content of a source matrix to the matrix instance.
Set(Murl.Math.Matrix m)
m | The matrix to copy from. |
Set the translation component to given values.
SetTranslationComponent(Number x, Number y, Number z)
x | The X translation component. |
y | The Y translation component. |
z | The Z translation component. |
Set the translation component to a given vector.
SetTranslationComponent(Murl.Math.Vector v)
v | The vector to set the translation component. |
Set the translation X component.
SetTranslationComponentX(Number x)
x | The X translation component. |
Set the translation Y component.
SetTranslationComponentY(Number y)
y | The Y translation component. |
Set the translation Z component.
SetTranslationComponentZ(Number z)
z | The Z translation component. |
Get the translation component vector.
Murl.Math.Vector GetTranslationComponent()
Get the translation component's X value.
Number GetTranslationComponentX()
Get the translation component's Y value.
Number GetTranslationComponentY()
Get the translation component's Z value.
Number GetTranslationComponentZ()
Set the scaling component using three distinct values. This method only sets the upper 3 diagonal elements of the matrix, so it should only be applied to matrices without rotation.
SetScalingComponent(Number x, Number y, Number z)
x | The X scaling factor. |
y | The Y scaling factor. |
z | The Z scaling factor. |
Set the scaling component using a vector. This method only sets the upper 3 diagonal elements of the matrix, so it should only be applied to matrices without rotation.
SetScalingComponent(Murl.Math.Vector v)
v | The vector containing X, Y and Z scaling components. |
Get a vector containing the X, Y and Z scaling components of the matrix.
Murl.Math.Vector GetScalingComponent()
Get the X scale value of the matrix.
Number GetScalingComponentX()
Get the Y scale value of the matrix.
Number GetScalingComponentY()
Get the Z scale value of the matrix.
Number GetScalingComponentZ()
Set the rotation component by euler angles. The default axis rotation order is IEnums::ROTATION_ORDER_ZYX.
SetRotationComponent(Number angleX, Number angleY, Number angleZ)
angleX | The x-axis angle in radiants. |
angleY | The y-axis angle in radiants. |
angleZ | The z-axis angle in radiants. |
Set the rotation component by an angle and vector.
SetRotationComponent(Number angle, Murl.Math.Vector axis)
angle | The angle of the rotation in radiants. |
axis | The vector of the rotation. |
Set the rotation component by a rotation matrix.
SetRotationComponent(Murl.Math.Matrix rotationMatrix)
rotationMatrix | The rotation matrix. |
Set the rotation component by a quaternion.
SetRotationComponent(Murl.Math.Quaternion q)
q | The quaternion. |
Set the rotation component by a vector.
SetRotationComponent(Murl.Math.Vector axisAngle)
axisAngle | The vector of the rotation including the angle in w component in radiants. |
Set the rotation component by an angle and vector components.
SetRotationComponentAxisAngle(Number angle, Number ax, Number ay, Number az)
angle | The angle of the rotation in radiants. |
ax | The x-component of the rotation vector. |
ay | The y-component of the rotation vector. |
az | The z-component of the rotation vector. |
Set the rotation component by euler angles with a given rotation order.
SetRotationComponentXYZ(Number angleX, Number angleY, Number angleZ, Murl.IEnums.RotationOrder rotationOrder)
angleX | The x-axis angle in radiants. |
angleY | The y-axis angle in radiants. |
angleZ | The z-axis angle in radiants. |
rotationOrder | The axis rotation order. |
Set the rotation component of the transformation matrix to only rotate around the X axis. This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit X axis. The angle value must be given in radians. A positive value result in a clockwise rotation.
SetRotationComponentX(Number angleX)
angleX | The x-axis angle in radiants. |
Set the rotation component of the transformation matrix to only rotate around the Y axis. This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit Y axis. The angle value must be given in radians. A positive value result in a clockwise rotation.
SetRotationComponentY(Number angleY)
angleY | The y-axis angle in radiants. |
Set the rotation component of the transformation matrix to only rotate around the Z axis. This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit Z axis. The angle value must be given in radians. A positive value result in a clockwise rotation.
SetRotationComponentZ(Number angleZ)
angleZ | The z-axis angle in radiants. |
Get the euler rotation angles. Extract the euer rotation angles based on https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2012/07/euler-angles.pdf
Murl.Math.Vector GetEulerRotation()
Extract the rotation and scaling component of the matrix.
Murl.Math.Matrix GetRotationAndScalingComponent()
Get the vector of a specified column.
Murl.Math.Vector GetColumnVector(Integer columnIndex)
columnIndex | The column index in range [0 .. 3]. |
Set a specified column by a vector. Hints are not considered.
SetColumnVector(Integer columnIndex, Murl.Math.Vector vec)
columnIndex | The column index in range [0 .. 3]. |
vec | The vector to set the colum at the specified index. |
Get the vector of a specified row.
Murl.Math.Vector GetRowVector(Integer rowIndex)
rowIndex | The row index in range [0 .. 3]. |
Set a specified row by a vector. Hints are not considered.
SetRowVector(Integer rowIndex, Murl.Math.Vector vec)
rowIndex | The row index in range [0 .. 3]. |
vec | The vector to set the row at the specified index. |
In-place matrix-matrix multiplication.
MultiplySelf(Murl.Math.Matrix m)
m | The matrix to multiply. |
In-place reverse matrix-matrix multiplication.
MultiplySelfReverse(Murl.Math.Matrix m)
m | The matrix to multiply. |
In-place transpose of the matrix.
TransposeSelf()
In-place inversion of the matrix.
InvertSelf()
Transform (multiply) a vector by the matrix.
Murl.Math.Vector Transform(Murl.Math.Vector v)
v | The vector to mulitply. |
Rotate a vector by the matrix.
Murl.Math.Vector Rotate(Murl.Math.Vector v)
v | The vector to rotate. |
Translate a vector by the matrix (add the translation component).
Murl.Math.Vector Translate(Murl.Math.Vector v)
v | The vector to translate. |
Multiply a matrix by the matrix.
Murl.Math.Matrix Multiply(Murl.Math.Matrix m)
m | The matrix to mulitply. |
Multiply a vector by the matrix.
Murl.Math.Vector Multiply(Murl.Math.Vector v)
v | The vector to mulitply. |
Get the transposed matrix.
Murl.Math.Matrix Transpose()
Fast inversion of a rotation/translation matrix. This method can be used to quickly invert a given matrix that is only made up from rotation and translation operations. If the matrix also contains any scaling operations, use InvertTransRotScl() instead. For general 4x4 matrices, use Invert().
Murl.Math.Matrix InvertTransRot()
Fast inversion of a rotation/translation/scaling matrix. This method can be used to quickly invert a given matrix that is only made up from rotation, translation and scaling operations. If only rotation and translation is present, use InvertTransRot(). For general 4x4 matrices, use Invert() instead.
Murl.Math.Matrix InvertTransRotScl()
Matrix inversion. This method can be used to calculate the inverse of a general 4x4 matrix. In case the matrix is only made up from rotation and translation operations, it is possible to use InvertTransRot() instead. If it also contains additional scaling operations, InvertTransRotScl() can be used; both alternative methods show better overall performance.
Murl.Math.Matrix Invert()
Solve the matrix by a vector.
Murl.Math.Vector Solve(Murl.Math.Vector v)
v | The vector to solve. |
Set a component element. Hints are not considered.
SetElementAt(Integer row, Integer col, Number value)
row | The row in range [0 .. 3]. |
col | The column in range [0 .. 3]. |
value | The value to set. |
Get a writeable reference to a component element.
Number GetElementAt(Integer row, Integer col)
row | The row in range [0 .. 3]. |
col | The column in range [0 .. 3]. |
Set a component element. Hints are not considered.
SetElement(Murl.Math.Matrix.Component element, Number value)
element | The element |
value | The value to set. |
Get a writeable reference to a component element.
Number GetElement(Murl.Math.Matrix.Component element)
element | The element's component. |
Set the XX component. Hints are not considered.
SetXX(Number value)
value | The XX component value to set. |
Set the XY component. Hints are not considered.
SetXY(Number value)
value | The XY component value to set. |
Set the XZ component. Hints are not considered.
SetXZ(Number value)
value | The XZ component value to set. |
Set the XW component. Hints are not considered.
SetXW(Number value)
value | The XW component value to set. |
Set the YX component. Hints are not considered.
SetYX(Number value)
value | The YX component value to set. |
Set the YY component. Hints are not considered.
SetYY(Number value)
value | The YY component value to set. |
Set the YZ component. Hints are not considered.
SetYZ(Number value)
value | The YZ component value to set. |
Set the YW component. Hints are not considered.
SetYW(Number value)
value | The YW component value to set. |
Set the ZX component. Hints are not considered.
SetZX(Number value)
value | The ZX component value to set. |
Set the ZY component. Hints are not considered.
SetZY(Number value)
value | The ZY component value to set. |
Set the ZZ component. Hints are not considered.
SetZZ(Number value)
value | The ZZ component value to set. |
Set the ZW component. Hints are not considered.
SetZW(Number value)
value | The ZW component value to set. |
Set the WX component. Hints are not considered.
SetWX(Number value)
value | The WX component value to set. |
Set the WY component. Hints are not considered.
SetWY(Number value)
value | The WY component value to set. |
Set the WZ component. Hints are not considered.
SetWZ(Number value)
value | The WZ component value to set. |
Set the WW component. Hints are not considered.
SetWW(Number value)
value | The WW component value to set. |
Get the XX component.
Number GetXX()
Get the XY component.
Number GetXY()
Get the XZ component.
Number GetXZ()
Get the XW component.
Number GetXW()
Get the YX component.
Number GetYX()
Get the YY component.
Number GetYY()
Get the YZ component.
Number GetYZ()
Get the YW component.
Number GetYW()
Get the ZX component.
Number GetZX()
Get the ZY component.
Number GetZY()
Get the ZZ component.
Number GetZZ()
Get the ZW component.
Number GetZW()
Get the WX component.
Number GetWX()
Get the WY component.
Number GetWY()
Get the WZ component.
Number GetWZ()
Get the WW component.
Number GetWW()
Check if the matrix is equal to a given matrix. Compares all values within the default epsilon range Limits::Epsilon().
Boolean IsEqual(Murl.Math.Matrix m)
m | The matrix to compare. |
Check if the matrix is equal to a given matrix. Compares all values within a given epsilon range.
Boolean IsEqual(Murl.Math.Matrix m, Number epsilon)
m | The matrix to compare. |
epsilon | The epsilon to compare. |
Check if the matrix is equal to the identity matrix. Performs a test without an epsilon range.
Boolean IsIdentity()
Check if the matrix is equal to the identity matrix. Compares all values within a given epsilon range.
Boolean IsIdentity(Number epsilon)
epsilon | The epsilon to compare. |
Get the string representation of the object.
String ToString()
Get the number of elements in the object.
Integer GetCount()
The length operator is denoted by the unary prefix operator #.
Converts the object content to a string in a reasonable format.
Get a writeable reference to a component element.
index | The component index, see enum Component. |
Matrix-matrix multiplication operator.
Matrix-vector multiplication operator.
Equal to comparison operator. Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Matrix> class. To compare within an epsilon range use Matrix::IsEqual().