Class: TransformUtils
Defined in: utils/TransformUtils.ts:10
Utility methods for converting between SimilarityTransform
objects and gl-matrix mat3 matrices
Constructors
Constructor
new TransformUtils():
TransformUtils
Returns
TransformUtils
Methods
compose()
staticcompose(tf,pivot?):mat3
Defined in: utils/TransformUtils.ts:66
Builds a 3×3 similarity matrix from a (partial) SimilarityTransform
Applies, in order: flip/scale, rotation, and translation.
If pivot is given, flip and rotation are applied about pivot (in the
source coordinates of the transform) instead of the origin, while scale
stays about the origin. The translation is then the position of the
scaled content before it is flipped and rotated about its (scaled)
pivot. This is the inverse of decompose called with
the same pivot.
Parameters
tf
Partial<SimilarityTransform>
The transform components (all optional)
pivot?
Optional point about which flip and rotation are applied
x
number
y
number
Returns
mat3
The composed matrix
decompose()
staticdecompose(m,pivot?):SimilarityTransform
Defined in: utils/TransformUtils.ts:30
Decomposes a 3×3 similarity matrix into a SimilarityTransform
Extracts flip, uniform scale, rotation (in degrees), and translation
from a column-major gl-matrix mat3. A negative 2D determinant
indicates a horizontal reflection.
If pivot is given, flip and rotation are expressed about pivot
(in the input coordinates of m) instead of the origin, while scale
stays about the origin. Flip, scale, and rotation are unaffected; only
the translation changes to m(pivot) - scale * pivot, i.e. the position
of the scaled content before it is flipped and rotated about its (scaled)
pivot. This matches viewers that place an image by its top-left corner
and then flip/rotate it about its center.
Parameters
m
mat3
The source matrix
pivot?
Optional point about which flip and rotation are expressed
x
number
y
number
Returns
The decomposed transform
transformBoundingBox()
statictransformBoundingBox(rect,m):Rect
Defined in: utils/TransformUtils.ts:103
Transforms an axis-aligned rectangle and returns the axis-aligned bounding box of the transformed corners
Parameters
rect
The rectangle to transform
m
mat3
The transformation matrix to apply to the rectangle corners
Returns
The axis-aligned bounding box of the transformed rectangle