matrix¶
-
class
guerilla.
matrix
¶ Bases:
object
A 4x4 transformation matrix
-
asarray
()¶ Converts the
matrix
as an array table of 16 numbersReturns: The corresponding array of numbers Return type: {number}
-
compose
(other)¶ Returns the composition of the two matrices
self will be applied first, then other.
Parameters: other ( matrix
) –Return type: matrix
-
copy
(source)¶ Copy the source matrix into this matrix
Parameters: source ( matrix
) – The matrix to copy
-
static
createcomposite
(sx, sy, sz, rx, ry, rz, tx, ty, tz)¶ Create the composite matrix using scale, rotation and translation. The scale factors are first applied, then x rotation, y rotation and z rotation, and the the translation is applied.
Parameters: - sx (number) – The x scale
- sy (number) – The y scale
- sz (number) – The z scale
- rx (number) – The x rotation angle in radian
- ry (number) – The y rotation angle in radian
- rz (number) – The z rotation angle in radian
- tx (number) – The x translation
- ty (number) – The y translation
- tz (number) – The z translation
Return type:
-
static
createfromarray
(array)¶ Create a new
matrix
object from a array table of numbersParameters: array ({number}) – The source array table of numbers Returns: The new matrix
objectReturn type: matrix
-
static
createlookat
(pos, target, roll, up, direction)¶ Compute a lookat matrix. pos and target must be specified. rool OR up can be specified.
Parameters: Returns: The lookup matrix
Return type:
-
decompose
()¶ Decompose the matrix into scale, rotation and translation components.
Returns: The decomposed matrix components Return type: number
-
equals
(other)¶ Compares this matrix to other matrix.
Parameters: other ( matrix
) –Returns: True if all values of the matrices are equal Return type: bool
-
static
fromarray
(array)¶ Create a new
matrix
object from a array table of numbersParameters: array ({number}) – The source array table of numbers Returns: The new matrix
objectReturn type: matrix
-
lookat
(position, target, up)¶ Set the matrix to look from position to target with up as roll.
Parameters:
-
normalize
()¶ Normalize the line components of the matrix.
-
pivot
(axis, angle, pivot)¶ Rotate this matrix around around a pivot, an axis and an angle in radian
Parameters:
-
rotate
(axis, angle)¶ Rotate the matrix around an axis with an angle in radian
Parameters: - axis (
point3
) – The rotation axis - angle (number) – The rotation angle
- axis (
-
rotatex
(angle)¶ Rotate the matrix around the x axis.
Parameters: angle (number) – The rotation angle in radians
-
rotatey
(angle)¶ Rotate the matrix around the y axis.
Parameters: angle (number) – The rotation angle in radians
-
rotatez
(angle)¶ Rotate the matrix around the z axis.
Parameters: angle (number) – The rotation angle in radians
-
scale
(scalex, scaley, scalez)¶ Scale the matrix on all axises.
Parameters: - scalex (number) – The scale factor on x axis
- scaley (number) – The scale factor on y axis
- scalez (number) – The scale factor on z axis
-
serialstring
()¶ Returns a Lua evaluable string to create this object
-
setidentity
()¶ Set the matrix to identity.
-
transform
(p)¶ Return the transform of the point p by the matrix. (p * self)
Parameters: p ( point3
) –Return type: point3
-