Module transform
Lua bindings to interact with transforms.
Functions
__tostring (t) | Gets a string representing the transform. |
__eq (t1, t2) | Compares two transforms to see if they are the same. |
new () | Creates a new identity transform.Gets a transform. |
__mul (A, B) | Multiplies two transforms (A*B). |
get (T) | Gets all the values of the transform. |
set (T, i, j, v) | Sets an element of a transform. |
scale (T, x, y, z) | Applies scaling to a transform. |
translate (T, x, y, z) | Applies translation to a transform. |
rotate2d (T, angle) | Applies a 2D rotation (along Z-axis) to a transform. |
translate (left, right, bottom, top, nearVal, farVal) | Creates an orthogonal matrix. |
applyPoint (T, x, y, z) | Applies a transformation to a point. |
applyDim (T, x, y, z) | Applies a transformation to a dimension. |
Functions
- __tostring (t)
-
Gets a string representing the transform.
Parameters:
- t Transform Transform to get string of.
Returns:
-
string
String corresponding to the transform.
- __eq (t1, t2)
-
Compares two transforms to see if they are the same.
Parameters:
- t1 Transform Transform 1 to compare.
- t2 Transform Transform 2 to compare.
Returns:
-
boolean
true if both transforms are the same.
- new ()
-
Creates a new identity transform.Gets a transform.
Returns:
-
Transform
A new transform corresponding to an identity matrix.
- __mul (A, B)
-
Multiplies two transforms (A*B).
Parameters:
- A Transform First element to multiply.
- B Transform Second element to multiply.
Returns:
-
Transform
Result of multiplication.
- get (T)
-
Gets all the values of the transform.
Note, this returns in column-major.
Parameters:
- T Transform Transform te get parameters of.
Returns:
-
table
2D table containing all the values of the transform.
- set (T, i, j, v)
-
Sets an element of a transform.
Parameters:
- T Transform Transform to set element of.
- i number Column to set.
- j number Row to set.
- v number Value to set to.
- scale (T, x, y, z)
-
Applies scaling to a transform.
Parameters:
- T Transform Transform to apply scaling to.
- x number X-axis scaling.
- y number Y-axis scaling.
- z number Z-axis scaling.
Returns:
-
Transform
A new transformation.
- translate (T, x, y, z)
-
Applies translation to a transform.
Parameters:
- T Transform Transform to apply translation to.
- x number X-axis translation.
- y number Y-axis translation.
- z number Z-axis translation.
Returns:
-
Transform
A new transformation.
- rotate2d (T, angle)
-
Applies a 2D rotation (along Z-axis) to a transform.
Parameters:
- T Transform Transform to apply rotation to.
- angle number Angle to rotate (radians).
- translate (left, right, bottom, top, nearVal, farVal)
-
Creates an orthogonal matrix.
Parameters:
- left number Left value.
- right number Right value.
- bottom number Bottom value.
- top number Top value.
- nearVal number value.
- farVal number value.
Returns:
-
Transform
A new transformation.
- applyPoint (T, x, y, z)
-
Applies a transformation to a point.
Parameters:
- T Transform Transform to apply.
- x number Point X-coordinate.
- y number Point Y-coordinate.
- z number Point Z-coordinate.
Returns:
- number New X coordinate.
- number New Y coordinate.
- number New Z coordinate.
- applyDim (T, x, y, z)
-
Applies a transformation to a dimension.
Note This is similar to Transform.applyPoint, except the translation is not applied.
Parameters:
- T Transform Transform to apply.
- x number Dimension X-coordinate.
- y number Dimension Y-coordinate.
- z number Dimension Z-coordinate.
Returns:
- number New X coordinate.
- number New Y coordinate.
- number New Z coordinate.