Skip to main content

Class: Transform2D

Defined in: src/sdk/math/Transform2D.ts:9

A 2D affine transformation. By default, Transform2D objects are initially created as identity transformations.

Constructors​

Constructor​

new Transform2D(): Transform2D

Returns​

Transform2D

Methods​

addReflection()​

Call Signature​

addReflection(theta, order?): this

Defined in: src/sdk/math/Transform2D.ts:411

Adds a reflection across a line passing through the origin (0, 0) to this transformation.

Parameters​
ParameterTypeDescription
thetanumberThe angle of the reflection line, in radians, with respect to the positive x axis.
order?"before" | "after"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.

Call Signature​

addReflection(theta, originX, originY, order?): this

Defined in: src/sdk/math/Transform2D.ts:421

Adds a reflection across a line passing through an arbitrary origin to this transformation.

Parameters​
ParameterTypeDescription
thetanumberThe angle of the reflection line, in radians, with respect to the positive x axis.
originXnumberThe x-coordinate of the reflection origin.
originYnumberThe y-coordinate of the reflection origin.
order?"before" | "after"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.


addRotation()​

Call Signature​

addRotation(theta, order?): this

Defined in: src/sdk/math/Transform2D.ts:370

Adds a rotation about the origin (0, 0) to this transformation.

Parameters​
ParameterTypeDescription
thetanumberThe rotation angle, in radians.
order?"before" | "after"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.

Call Signature​

addRotation(theta, originX, originY, order?): this

Defined in: src/sdk/math/Transform2D.ts:380

Adds a rotation about an arbitrary origin to this transformation.

Parameters​
ParameterTypeDescription
thetanumberThe rotation angle, in radians.
originXnumberThe x-coordinate of the rotation origin.
originYnumberThe y-coordinate of the rotation origin.
order?"before" | "after"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.


addScale()​

Call Signature​

addScale(x, y, order?): this

Defined in: src/sdk/math/Transform2D.ts:328

Adds a scaling about the origin (0, 0) to this transformation.

Parameters​
ParameterTypeDescription
xnumberThe x scaling factor.
ynumberThe y scaling factor.
order?"before" | "after"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.

Call Signature​

addScale(x, y, originX, originY, order?): this

Defined in: src/sdk/math/Transform2D.ts:339

Adds a scaling about an arbitrary origin to this transformation.

Parameters​
ParameterTypeDescription
xnumberThe x scaling factor.
ynumberThe y scaling factor.
originXnumberThe x-coordinate of the scaling origin.
originYnumberThe y-coordinate of the scaling origin.
order?"before" | "after"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.


addTranslation()​

addTranslation(x, y, order): this

Defined in: src/sdk/math/Transform2D.ts:308

Adds a translation to this transformation.

Parameters​

ParameterTypeDefault valueDescription
xnumberundefinedThe x translation.
ynumberundefinedThe y translation.
order"before" | "after"'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.


apply()​

apply(vec, out): Float64Array

Defined in: src/sdk/math/Transform2D.ts:179

Applies this transformation to a 2D vector.

Parameters​

ParameterTypeDescription
vecReadonlyFloat64ArrayA 2D vector.
outFloat64ArrayThe vector to which to write the result.

Returns​

Float64Array

The result of applying this transformation to vec.


copy()​

copy(): Transform2D

Defined in: src/sdk/math/Transform2D.ts:169

Copies this transformation.

Returns​

Transform2D

A copy of this transformation.


getParameters()​

getParameters(): ReadonlyFloat64Array

Defined in: src/sdk/math/Transform2D.ts:16

Gets the parameters of this transformation as a 6-tuple: [scaleX, skewX, translateX, skewY, scaleY, translateY].

Returns​

ReadonlyFloat64Array

The parameters of this transformation.


invert()​

invert(): this

Defined in: src/sdk/math/Transform2D.ts:141

Inverts this transformation.

Returns​

this

This transformation, after it has been inverted.


offsetOrigin()​

offsetOrigin(x, y): this

Defined in: src/sdk/math/Transform2D.ts:195

Changes this transformation to the one that is the result of offsetting this transformation's origin.

Parameters​

ParameterTypeDescription
xnumberThe x-coordinate of the offset origin.
ynumberThe y-coordinate of the offset origin.

Returns​

this

This transformation, after it has been changed.


set()​

Call Signature​

set(scaleX, skewX, translateX, skewY, scaleY, translateY): this

Defined in: src/sdk/math/Transform2D.ts:30

Sets the parameters of this transformation.

Parameters​
ParameterTypeDescription
scaleXnumberThe x scaling factor.
skewXnumberThe x skew factor.
translateXnumberThe x translation.
skewYnumberThe y skew factor.
scaleYnumberThe y scaling factor.
translateYnumberThe y translation.
Returns​

this

This transformation, after it has been changed.

Call Signature​

set(transform): this

Defined in: src/sdk/math/Transform2D.ts:35

Sets the parameters of this transformation from another transformation.

Parameters​
ParameterTypeDescription
transformReadonlyTransform2DThe transformation from which to take parameters.
Returns​

this


setScale()​

setScale(x, y): this

Defined in: src/sdk/math/Transform2D.ts:79

Sets the x and y scaling factors of this transformation.

Parameters​

ParameterTypeDescription
xnumberThe new x scaling factor.
ynumberThe new y scaling factor.

Returns​

this

This transformation, after it has been changed.


setScaleX()​

setScaleX(value): this

Defined in: src/sdk/math/Transform2D.ts:58

Sets the x scaling factor of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new x scaling factor.

Returns​

this

This transformation, after it has been changed.


setScaleY()​

setScaleY(value): this

Defined in: src/sdk/math/Transform2D.ts:68

Sets the y scaling factor of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new y scaling factor.

Returns​

this

This transformation, after it has been changed.


setSkewX()​

setSkewX(value): this

Defined in: src/sdk/math/Transform2D.ts:90

Sets the x skew factor of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new x skew factor.

Returns​

this

This transformation, after it has been changed.


setSkewY()​

setSkewY(value): this

Defined in: src/sdk/math/Transform2D.ts:100

Sets the y skew factor of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new y skew factor.

Returns​

this

This transformation, after it has been changed.


setTranslate()​

setTranslate(x, y): this

Defined in: src/sdk/math/Transform2D.ts:131

Sets the x and y translations of this transformation.

Parameters​

ParameterTypeDescription
xnumberThe new x translation.
ynumberThe new y translation.

Returns​

this

This transformation, after it has been changed.


setTranslateX()​

setTranslateX(value): this

Defined in: src/sdk/math/Transform2D.ts:110

Sets the x translation of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new x translation.

Returns​

this

This transformation, after it has been changed.


setTranslateY()​

setTranslateY(value): this

Defined in: src/sdk/math/Transform2D.ts:120

Sets the y translation of this transformation.

Parameters​

ParameterTypeDescription
valuenumberThe new y translation.

Returns​

this

This transformation, after it has been changed.


toIdentity()​

toIdentity(): this

Defined in: src/sdk/math/Transform2D.ts:207

Sets this transformation to the identity transformation.

Returns​

this

This transformation, after it has been changed.


toReflection()​

Call Signature​

toReflection(theta): this

Defined in: src/sdk/math/Transform2D.ts:277

Sets this transformation to a reflection across a line passing through the origin (0, 0).

Parameters​
ParameterTypeDescription
thetanumberThe angle of the reflection line, in radians, with respect to the positive x axis.
Returns​

this

This transformation, after it has been changed.

Call Signature​

toReflection(theta, originX, originY): this

Defined in: src/sdk/math/Transform2D.ts:285

Sets this transformation to a reflection across a line passing through an arbitrary origin.

Parameters​
ParameterTypeDescription
thetanumberThe angle of the reflection line, in radians, with respect to the positive x axis.
originXnumberThe x-coordinate of the reflection origin.
originYnumberThe y-coordinate of the reflection origin.
Returns​

this

This transformation, after it has been changed.


toRotation()​

Call Signature​

toRotation(theta): this

Defined in: src/sdk/math/Transform2D.ts:251

Sets this transformation to a rotation about the origin (0, 0).

Parameters​
ParameterTypeDescription
thetanumberThe rotation angle, in radians.
Returns​

this

This transformation, after it has been changed.

Call Signature​

toRotation(theta, originX, originY): this

Defined in: src/sdk/math/Transform2D.ts:259

Sets this transformation to a rotation about an arbitrary origin.

Parameters​
ParameterTypeDescription
thetanumberThe rotation angle, in radians.
originXnumberThe x-coordinate of the rotation origin.
originYnumberThe y-coordinate of the rotation origin.
Returns​

this

This transformation, after it has been changed.


toScale()​

Call Signature​

toScale(x, y): this

Defined in: src/sdk/math/Transform2D.ts:227

Sets this transformation to a scaling about the origin (0, 0).

Parameters​
ParameterTypeDescription
xnumberThe x scaling factor.
ynumberThe y scaling factor.
Returns​

this

This transformation, after it has been changed.

Call Signature​

toScale(x, y, originX, originY): this

Defined in: src/sdk/math/Transform2D.ts:236

Sets this transformation to a scaling about an arbitrary origin.

Parameters​
ParameterTypeDescription
xnumberThe x scaling factor.
ynumberThe y scaling factor.
originXnumberThe x-coordinate of the scaling origin.
originYnumberThe y-coordinate of the scaling origin.
Returns​

this

This transformation, after it has been changed.


toTranslation()​

toTranslation(x, y): this

Defined in: src/sdk/math/Transform2D.ts:217

Sets this transformation to a translation.

Parameters​

ParameterTypeDescription
xnumberThe x translation.
ynumberThe y translation.

Returns​

this

This transformation, after it has been changed.


concat()​

static concat<T>(out, transforms): T

Defined in: src/sdk/math/Transform2D.ts:458

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​

Type Parameter
T extends Transform2D

Parameters​

ParameterTypeDescription
outTThe transformation to which to write the result.
transformsreadonly ReadonlyTransform2D[]The transformations to concatenate, in order.

Returns​

T

The result of concatenating all transformations in transforms.