1.41 Matrix44 . 1.41.1 Matrix44.Add . 1.41.2 Matrix44.Copy . 1.41.3 Matrix44.Create . 1.41.4 Matrix44.GetRotationXyz . 1.41.5 Matrix44.GetRow . 1.41.6 Matrix44.Invert . 1.41.7 Matrix44.lnvertAffine . 1.41.8 Matrix44.lnvertAffineOrthogonal . 1.41.9 Matrix44.lsEqual . 1.41.10 Matrix44.Isldentity . 1.41.11 Matrix44.Multiply . 1.41.12 Matrix44.0rthonormalize . 1.41.13 Matrix44.SetAxisRotation . 1.41.14 Matrix44.Setldentity . 1.41.15 Matrix44.SetRotationQuat . 1.41.16 Matrix44.SetRotationXyz . 1.41.17 Matrix44.SetRow . 1.41.18 Matrix44.SetScale . 1.41.19 Matrix44.SetTranslation . 1.41.20 Matrix44.Subtract . 1.41.21 Matrix44.Transpose . Matrix44 Matrix44.Add Brief Performs a matrix addition with sourcel and source2 storing the result in destination. Definition Matrix44.Add( Matrix44 destination, Matrix44 sourcel, Matrix44 source2 ) Arguments destination - Matrix to receive the result.sourcel - The first matrix argument for the addition.source2 - The second matrix argument for the addition. Return Values None. Description Performs a matrix addition with sourcel and source2 storing the result in destination. Equivalent to destination = sourcel + source2, but the operator syntax will allocate the destination automatically. Examples srcl = Matrix44.Create() src2 = Matrix44.Create() dst = Matrix44.Create() Matrix44.Add( dst, srcl, src2 ) See Also Matrix44.Subtract Matrix44.Copy Brief Copies the values of source and stores them in the destination Matrix44. Definition Matrix44.Copy( Matrix44 destination, Matrix44 source ) Arguments destination - The matrix to receive the copy.source - The matrix to be copied. Return Values None Description Copies the values of source and stores them in the destination Matrix44. This is used to copy the values as opposed to pointing to the same matrix as an assignment would do. Use copy as mat2 = matl does not copy values but instead makes mat2 point to matl. Examples matl = Matrix44.Create() i mat2 = Matrix44.Create() I Matrix44.Copy( mat2, matl ) See Also None Matrix44.Create Brief Creates a new Matrix44 object with the specified values. Definition Matrix44 Matrix44.Create( Vector4 x = [1,0,0,0], Vector4 y = [0,1,0,0], Vector4 z = [0,0,1,0], Vector4 w = [0,0,0,1] ) Matrix44 Matrix44.Create( Matrix44 matrix ) Matrix44 Matrix44.Create( Quaternion rotation, Vector4 translation = [0,0,0] ) Arguments x - The first row of the matrix.y - The second row of the matrix.z - The third row of the matrix.w - The fourth row of the matrix.matrix - The matrix to copy.rotation - The quaternion representing the rotation part of the transform.translation - The vector representing the translation part of the transform. Return Values A new Matrix44 instance. Description Creates a new Matrix44 object with the specified values. With no parameters specified, it is set to the identity matrix. Examples matl = Matrix44.Create() vec = Vector4.Create( 1, 2, 3, 4 ) mat2 = Matrix44.Create( vec, vec, vec, vec ) mat3 = Matrix44.Create( mat2 ) mat4 = Matrix44.Create( Quaternion.Create() ) See Also None Matrix44.GetRotationXyz Brief Gets the rotation about the x, y, and z-axis in degrees. Definition Vector4 Matrix44.GetRotationXyz( Matrix44 matrix ) Matrix44.GetRotationXyz( Matrix44 matrix, Vector4 outVec ) Arguments matrix - The matrix to query.outVec - The Vector4 to store the result to. Return Values A vector containing the x, y, z rotation angles. Description Gets the rotation about the x, y, and z-axis in degrees using a matrix to Euler angle formula. The rotation order is x, y, z. If outVec is specified it stores the result in there instead of returning a new Vector4. Examples matrix = Matrix44.Create() ; rotation = Matrix44.GetRotationXyz( matrix ) See Also • Entity.SetRotationXyz Matrix44.GetRow Brief Returns the specified row of the matrix. Definition Vector4 Matrix44.GetRow( Matrix44 matrix, number row ) Matrix44.GetRow( Matrix44 matrix, number row, Vector4 outVec ) Arguments matrix - The matrix to be queried.row - The row to return, ranging from 1 to 4.outVec - The Vector4 to store the result to. Return Values A vector representing the specified row of the matrix. Description Returns the specified row of the matrix. The Vector4 is a copy of the row so changing its values will not affect the matrix. If outVec is specified it stores the result in there instead of returning a new Vector4. Examples ! mat = Matrix44.Create() i print( Matrix44.GetRow( mat, 1 ) ) See Also • Matrix44.SetRow Matrix44.Invert Brief Inverts the source matrix storing it in destination. Definition Matrix44.Invert( Matrix44 destination, Matrix44 source ) Arguments destination - The matrix to receive the inverted matrix. Can be the source matrix.source - The matrix to invert. Return Values None Description Inverts the source matrix storing it in destination. Examples ! matrix = Matrix44.Create() j Matrix44.Invert( matrix, matrix ) — Self inverse. See Also None Matrix44.lnvertAffine Brief Inverts the source matrix, which is assumed to be an affine transform, storing it in destination. Definition Matrix44.InvertAffine( Matrix44 destination, Matrix44 source ) Arguments destination - The matrix to receive the inverted matrix. Can be the source matrix.source - The affine transform matrix to invert. Return Values None. Description For matrices representing an affine transform (that is, containing only scale, rotation and translation), this function will be faster than the general purpose Invert function. If your transform is only composed of rotation and translation (no scale), use the InvertAffineOrthogonal function, which is faster again. Examples ! matrix = Matrix44.Create() | Matrix44.InvertAffine( matrix, matrix ) — Self inverse. See Also • Matrix44.Invert • Matrix44. InvertAffineOrthogonal Matrix44.InvertAffineOrthogonal Brief Inverts the source matrix, which is assumed to be a transform containing only rotation and translation, storing it in destination. Definition Matrix44.InvertAffineOrthogonal( Matrix44 destination, Matrix44 source ) Arguments destination - The matrix to receive the inverted matrix. Can be the source matrix.source - The transform matrix to invert. Return Values None. Description If your matrix contains only rotation and translation (no scale), this function will calculate the inverse using an optimized method that is faster than both the general purpose Invert function and the InvertAffine function. Examples matrix = Matrix44.Create() Matrix44.InvertAffineOrthogonal( matrix, matrix ) — Self inverse. See Also • Matrix44.lnvertAffine • Matrix44.Invert Matrix44.lsEqual Brief Tests whether the specified matrices are equal. Definition boolean Matrix44.IsEqual( Matrix44 ml, Matrix44 m2, number tolerance = 0 ) Arguments ml - The first matrix to test for equality.m2 - The second matrix to test for equality .tolerance - The amount of error to deviate from the other matrix. Return Values true if it the matrices are equal and false otherwise. Description Returns true if it the matrices are equal and false otherwise. Examples 1 matl = Matrix44.Create() i mat2 = Matrix44.Create() j print( Matrix44.IsEqual( matl, mat2 ) ) See Also None Matrix44.lsldentity Brief Tests whether the specified matrix is an identity matrix. Definition boolean Matrix44.Isldentity( Matrix44 matrix, number tolerance = 0 ) Arguments matrix - The matrix to query.tolerance - The amount of error to deviate from the identity matrix. Return Values true if it is an identity matrix and false otherwise. Description Returns true if it is an identity matrix and false otherwise. Examples ! matrix = Matrix44.Create() i print( Matrix44.Isldentity( matrix ) ) See Also None Matrix44.Multiply Brief Performs a matrix multiply with sourcel and source2 storing the result in destination. Definition Matrix44.Multiply( Matrix44 destination, Matrix44 sourcel, Matrix44 source2 ) Matrix44.Multiply( Matrix44 destination, number scalar, Matrix44 matrix ) Matrix44.Multiply( Matrix44 destination, Matrix44 matrix, number scalar ) Arguments sourcel - The first matrix argument for the multiplication.source2 - The second matrix argument for the multiplication.scalar - Scalar to multiply.matrix - Matrix to multiply. Return Values None Description Performs a matrix multiply with sourcel and source2, or a scalar multiply with scalar and matrix, storing the result in destination. Equivalent to destination = sourcel * source2 or destination = scalar * matrix, but the operator syntax will allocate the destination automatically. Examples srcl = Matrix44.Create () src2 = Matrix44.Create () dst = Matrix44.Create () Matrix44.Multiply( dst, srcl, src2 ) Matrix44.Multiply( dst, srcl, 0.5 ) Matrix44.Multiply( dst, 2, src2 ) See Also None Matrix44.0rthonormalize Brief Orthonormalizes the source matrix storing it in destination. Definition Matrix44.Orthonormalize( Matrix44 destination, Matrix44 source, string axisPriority ) Arguments destination - The matrix to receive the orthonormalized matrix. Can be the source matrix.source - The matrix to orthonormalize.axisPriority - A string representing the axis priority of the operation, eg "yxz". Return Values None Description Orthonormalizes the source matrix storing it in destination. The first letter in the axis priority string specifies the axis whose direction will not be changed due to the orthogonalisation. The last specifies the axis whose direction will change the most due to the orthogonalisation. Note that if it is only necessary to remove scale, it is enough to normalise the three basis vectors rather than calling this function. Examples matrix = Matrix44.Create() Matrix44.Orthonormalize( matrix, matrix ) — Self orthonormalize. See Also None Matrix44.SetAxisRotation Brief Sets up a rotation matrix around a specified axis and angle. Definition Matrix44.SetAxisRotation( Matrix44 matrix, Vector4 rotationXyz, number angle = 0, number setType = MATRIX_POSTMULTIPLY ) Matrix44.SetAxisRotation( Matrix44 matrix, number axisX = 1, number axisY = 1, number axisZ = 1, number angle = 0, number setType = MATRIX_POSTMULTIPLY ) Arguments matrix - The matrix to be rotated.rotationXyz - A vector containing the axis to rotate about.angle - The angle in degrees to rotate around the axis.axisX - The x element of the axis.axisY - The y element of the axis.axisZ - The z element of the axis.setType - How to set the matrix. Must be either MATRIX_POSTMULTIPLY, MATRIX_PREMULTIPLY, or MATRIX_REPLACE. Return Values None Description Sets up a rotation matrix around a specified axis and angle. Depending on the set type it either post multiplies the current matrix by the rotation matrix (matrix = matrix * rotation), pre multiplies the current matrix by the rotation matrix (matrix = rotation * matrix) or simply sets the current matrix to the rotation matrix (matrix = rotation). Non normalized axes are automatically normalized. Examples matrix = Matrix44.Create() Matrix4 4.SetAxisRotation( matrix, 0.5, 0.5, 0, 90, MATRIX_REPLACE ) See Also None Matrix44.Setldentity Brief Sets the matrix to the identity matrix. Definition Matrix44.Setldentity( Matrix44 matrix ) Arguments matrix - The matrix to set to identity. Return Values None Description Sets the matrix to the identity matrix. Examples ! matrix = Matrix44.Create() ; Matrix44.Setldentity( matrix ) See Also • Matrix44.lsldentity Matrix44.SetRotationQuat Brief Sets up a rotation matrix using the specified quaternion. Definition Matrix44.SetRotationQuat( Matrix44 matrix, Quaternion quat, number setType = MATRIX_POSTMULTIPLY ) Arguments matrix - The matrix to be rotated.quat - The quaternion to convert.setType - How to set the matrix. Must be either MATRIX_POSTMULTIPLY, MATRIX_PREMULTIPLY, or MATRIX_REPLACE. Return Values None Description Sets up a rotation matrix using a specified quaternion. Depending on the set type it either post multiplies the current matrix by the rotation matrix (matrix = matrix * rotation), pre multiplies the current matrix by the rotation matrix (matrix = rotation * matrix) or simply sets the current matrix to the rotation matrix (matrix = rotation). Examples matrix = Matrix44.Create() quat = Quaternion.Create() Matrix44.SetRotationQuat( matrix, quat, MATRIX_REPLACE ) See Also None Matrix44.SetRotationXyz Brief Sets up a rotation matrix from x, y, and z euler angles specified in degrees. Definition Matrix44.SetRotationXyz( Matrix44 matrix, Vector4 rotationXyz, number setType = MATRIX_POSTMULTIPLY ) Matrix44.SetRotationXyz( Matrix44 matrix, number rotationX = 1, number rotationY = 1, number rotationZ = 1, number setType = MATRIX_POSTMULTIPLY ) Arguments matrix - The matrix to be rotated.rotationXyz - A vector containing the x, y and z euler angles in degrees to set the rotation matrix to.rotationX - A number containing the x euler angle in degrees to set the rotation matrix to.rotationY - A number containing the x euler angle in degrees to set the rotation matrix to.rotationZ - A number containing the x euler angle in degrees to set the rotation matrix to.setType - How to set the matrix. Must be either MATRIX_POSTMULTIPLY, MATRIX_PREMULTIPLY, or MATRIX_REPLACE. Return Values None Description Sets up a rotation matrix from x, y, and z euler angles specified in degrees. Depending on the set type it either post multiplies the current matrix by the rotation matrix (matrix = matrix * rotation), pre multiplies the current matrix by the rotation matrix (matrix = rotation * matrix) or simply sets the current matrix to the rotation matrix (matrix = rotation). The rotation order is x, y, z. Examples matrix = Matrix44.Create() Matrix44.SetRotationXyz( matrix, 45, 90, 180, MATRIX_REPLACE ) See Also None Matrix44.SetRow Brief Sets the specified row of the matrix. Definition Matrix44.SetRow( Matrix44 matrix, number row, Vector4 value ) Matrix44.SetRow( Matrix44 matrix, number row, number eleml, number elem2, number elem3, number elem4 ) Arguments matrix - The matrix to be updated.row - The row to set, ranging from 1 to 4.value - A 4 dimensional vector that is copied into the first row of the matrix.eleml - Value to set column 1 of the specified row of the matrix.elem2 - Value to set column 2 of the specified row of the matrix.elem3 - Value to set column 3 of the specified row of the matrix.elem4 - Value to set column 4 of the specified row of the matrix. Return Values None Description Sets the specified row of the matrix. Examples mat = Matrix44.Create () — Example 1: Set via vector vec = Vector4.Create( 1, 2, 3, 4 ) Matrix44.SetRow( mat, 3, vec ) — Example 2: Set via numbers Matrix44.SetRow( mat, 3, 1, 2, 3, 4 ) See Also • Matrix44.GetRow Matrix44.SetScale Brief Sets up a scale matrix. Definition Matrix44.SetScale( Matrix44 matrix, Vector4 scaleXyzw, number setType = MATRIX_POSTMULTIPLY ) Matrix44.SetScale( Matrix44 matrix, number scaleX = 1, number scaleY = 1, number scaleZ = 1, number scaleW = 1, number setType = MATRIX_POSTMULTIPLY ) Arguments matrix - The matrix to be scaled.scaleXyzw - A vector containing the x, y, z and w scale to set the matrix to.scaleX - A number containing the x scale to set the matrix to.scaleY - A number containing the y scale to set the matrix to.scaleZ - A number containing the z scale to set the matrix to.scaleW - A number containing the w scale to set the matrix to.setType - How to set the matrix. Must be either MATRIX_POSTMULTIPLY, MATRIX_PREMULTIPLY, or MATRIX_REPLACE. Return Values None Description Sets up a scale matrix and depending on the set type it either post multiplies the current matrix by the scale matrix (matrix = matrix * scale), pre multiplies the current matrix by the scale matrix (matrix = scale * matrix) or simply sets the current matrix to the scale matrix (matrix = scale). Examples matrix = Matrix44.Create() Matrix44.SetScale( matrix, 4, 3, 2, 1, MATRIX_REPLACE ) See Also None Matrix44.SetT ranslation Brief Sets up a translation matrix Definition Matrix44.SetTranslation( Matrix44 matrix, Vector4 translationXyz, number setType = MATRIX_POSTMULTIPLY ) Matrix44.SetTranslation( Matrix44 matrix, number translationX = 1, number translationY = 1, number translationZ = 1, number setType = MATRIX_POSTMULTIPLY ) Arguments matrix - The matrix to be translated.translationXyz - A vector containing the x, y, and z translation to set the matrix to.translationX - A number containing the x translation to set the matrix to.translationY - A number containing the y translation to set the matrix to.translationZ - A number containing the z translation to set the matrix to.setType - How to set the matrix. Must be either MATRIX_POSTMULTIPLY, MATRIX_PREMULTIPLY, or MATRIX_REPLACE. Return Values None Description Sets up a translation matrix and depending on the set type it either post multiplies the current matrix by the translation matrix (matrix = matrix * translation), pre multiplies the current matrix by the translation matrix (matrix = translation * matrix) or simply sets the current matrix to the translation matrix (matrix = translation). Examples matrix = Matrix44.Create() Matrix44.SetTranslation( matrix, 5, 10, 5, MATRIX_REPLACE ) See Also None Matrix44.Subtract Brief Performs a matrix subtraction with sourcel and source2 storing the result in destination. Definition Matrix44.Subtract( Matrix44 destination, Matrix44 sourcel, Matrix44 source2 ) Arguments destination - Matrix to receive the result.sourcel - The first matrix argument for the subtraction.source2 - The second matrix argument for the subtraction. Return Values None. Description Performs a matrix subtraction with sourcel and source2 storing the result in destination. Equivalent to destination = sourcel - source2, but the operator syntax will allocate the destination automatically. Examples srcl = Matrix44.Create () src2 = Matrix44.Create () dst = Matrix44.Create () Matrix44.Subtract( dst, srcl, src2 ) See Also • Matrix44.Add Matrix44.T ranspose Brief Transposes the source matrix storing it in destination. Definition Matrix44.Transpose( Matrix44 destination, Matrix44 source ) Arguments destination - The matrix to receive the transposed matrix. Can be the source matrix.source - The matrix to transpose. Return Values None Description Transposes the source matrix storing it in destination. Examples ! matrix = Matrix44.Create() ; Matrix44.Transpose( matrix, matrix ) — Self transpose. See Also