Class: Transform2D
A 2D affine transformation. By default, Transform2D objects are initially created as identity transformations.
Constructors
constructor
• new Transform2D(): Transform2D
Returns
Methods
addReflection
▸ addReflection(theta
, order?
): this
Adds a reflection across a line passing through the origin (0, 0) to this transformation.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
order? | "after" | "before" | The order in which to add the reflection, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:411
▸ addReflection(theta
, originX
, originY
, order?
): this
Adds a reflection across a line passing through an arbitrary origin to this transformation.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
originX | number | The x-coordinate of the reflection origin. |
originY | number | The y-coordinate of the reflection origin. |
order? | "after" | "before" | The order in which to add the reflection, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:421
addRotation
▸ addRotation(theta
, order?
): this
Adds a rotation about the origin (0, 0) to this transformation.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
order? | "after" | "before" | The order in which to add the rotation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:370
▸ addRotation(theta
, originX
, originY
, order?
): this
Adds a rotation about an arbitrary origin to this transformation.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
originX | number | The x-coordinate of the rotation origin. |
originY | number | The y-coordinate of the rotation origin. |
order? | "after" | "before" | The order in which to add the rotation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:380
addScale
▸ addScale(x
, y
, order?
): this
Adds a scaling about the origin (0, 0) to this transformation.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
order? | "after" | "before" | The order in which to add the scaling, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:328
▸ addScale(x
, y
, originX
, originY
, order?
): this
Adds a scaling about an arbitrary origin to this transformation.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
originX | number | The x-coordinate of the scaling origin. |
originY | number | The y-coordinate of the scaling origin. |
order? | "after" | "before" | The order in which to add the scaling, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:339
addTranslation
▸ addTranslation(x
, y
, order?
): this
Adds a translation to this transformation.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
x | number | undefined | The x translation. |
y | number | undefined | The y translation. |
order | "after" | "before" | 'after' | The order in which to add the translation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:308
apply
▸ apply(vec
, out
): Float64Array
Applies this transformation to a 2D vector.
Parameters
Name | Type | Description |
---|---|---|
vec | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | A 2D vector. |
out | Float64Array | The vector to which to write the result. |
Returns
Float64Array
The result of applying this transformation to vec
.
Defined in
src/sdk/math/Transform2D.ts:179
copy
▸ copy(): Transform2D
Copies this transformation.
Returns
A copy of this transformation.
Defined in
src/sdk/math/Transform2D.ts:169
getParameters
▸ getParameters(): Readonly
<Omit
<Float64Array
, "set"
| "sort"
| "copyWithin"
>>
Gets the parameters of this transformation as a 6-tuple: [scaleX, skewX, translateX, skewY, scaleY, translateY]
.
Returns
Readonly
<Omit
<Float64Array
, "set"
| "sort"
| "copyWithin"
>>
The parameters of this transformation.
Defined in
src/sdk/math/Transform2D.ts:16
invert
▸ invert(): this
Inverts this transformation.
Returns
this
This transformation, after it has been inverted.
Defined in
src/sdk/math/Transform2D.ts:141
offsetOrigin
▸ offsetOrigin(x
, y
): this
Changes this transformation to the one that is the result of offsetting this transformation's origin.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x-coordinate of the offset origin. |
y | number | The y-coordinate of the offset origin. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:195
set
▸ set(scaleX
, skewX
, translateX
, skewY
, scaleY
, translateY
): this
Sets the parameters of this transformation.
Parameters
Name | Type | Description |
---|---|---|
scaleX | number | The x scaling factor. |
skewX | number | The x skew factor. |
translateX | number | The x translation. |
skewY | number | The y skew factor. |
scaleY | number | The y scaling factor. |
translateY | number | The y translation. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:30
▸ set(transform
): this
Sets the parameters of this transformation from another transformation.
Parameters
Name | Type | Description |
---|---|---|
transform | ReadonlyTransform2D | The transformation from which to take parameters. |
Returns
this
Defined in
src/sdk/math/Transform2D.ts:35
setScale
▸ setScale(x
, y
): this
Sets the x and y scaling factors of this transformation.
Parameters
Name | Type | Description |
---|---|---|
x | number | The new x scaling factor. |
y | number | The new y scaling factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:79
setScaleX
▸ setScaleX(value
): this
Sets the x scaling factor of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new x scaling factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:58
setScaleY
▸ setScaleY(value
): this
Sets the y scaling factor of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new y scaling factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:68
setSkewX
▸ setSkewX(value
): this
Sets the x skew factor of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new x skew factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:90
setSkewY
▸ setSkewY(value
): this
Sets the y skew factor of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new y skew factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:100
setTranslate
▸ setTranslate(x
, y
): this
Sets the x and y translations of this transformation.
Parameters
Name | Type | Description |
---|---|---|
x | number | The new x translation. |
y | number | The new y translation. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:131
setTranslateX
▸ setTranslateX(value
): this
Sets the x translation of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new x translation. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:110
setTranslateY
▸ setTranslateY(value
): this
Sets the y translation of this transformation.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new y translation. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:120
toIdentity
▸ toIdentity(): this
Sets this transformation to the identity transformation.
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:207
toReflection
▸ toReflection(theta
): this
Sets this transformation to a reflection across a line passing through the origin (0, 0).
Parameters
Name | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:277
▸ toReflection(theta
, originX
, originY
): this
Sets this transformation to a reflection across a line passing through an arbitrary origin.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
originX | number | The x-coordinate of the reflection origin. |
originY | number | The y-coordinate of the reflection origin. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:285
toRotation
▸ toRotation(theta
): this
Sets this transformation to a rotation about the origin (0, 0).
Parameters
Name | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:251
▸ toRotation(theta
, originX
, originY
): this
Sets this transformation to a rotation about an arbitrary origin.
Parameters
Name | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
originX | number | The x-coordinate of the rotation origin. |
originY | number | The y-coordinate of the rotation origin. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:259
toScale
▸ toScale(x
, y
): this
Sets this transformation to a scaling about the origin (0, 0).
Parameters
Name | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:227
▸ toScale(x
, y
, originX
, originY
): this
Sets this transformation to a scaling about an arbitrary origin.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
originX | number | The x-coordinate of the scaling origin. |
originY | number | The y-coordinate of the scaling origin. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:236
toTranslation
▸ toTranslation(x
, y
): this
Sets this transformation to a translation.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x translation. |
y | number | The y translation. |
Returns
this
This transformation, after it has been changed.
Defined in
src/sdk/math/Transform2D.ts:217
concat
▸ concat<T
>(out
, transforms
): T
Concatenates one or more transformations and returns the result. Concatenating transformations [A, B, ...]
results in a transformation that is equivalent to first applying A
, then applying B
, etc. Note that this order
is the opposite of the one resulting from multiplying the individual transformation matrices
M_A * M_B * ...
.
If the number of transformations to concatenate equals zero, the identity matrix is returned.
Type parameters
Name | Type |
---|---|
T | extends Transform2D |
Parameters
Name | Type | Description |
---|---|---|
out | T | The transformation to which to write the result. |
transforms | readonly ReadonlyTransform2D [] | The transformations to concatenate, in order. |
Returns
T
The result of concatenating all transformations in transforms
.
Defined in
src/sdk/math/Transform2D.ts:458