Hide menu
Loading...
Searching...
No Matches
Transformation2d

Describes a transformation in 2D space.

A transformation consists of a rotation matrix, a translation vector, and a scale factor.

Constructors

Constructor

new Transformation2d(rotation?, translation?, scaleFactor?): Transformation2d

Creates a transformation from rotation, translation, and scale components.

If all arguments are omitted, an identity transformation is created.

Parameters

rotation?

Matrix2d

Rotation matrix of the transformation.

translation?

Vector2d

Translation vector of the transformation.

scaleFactor?

number

Scale factor.

Returns

Transformation2d

Constructor

new Transformation2d(point, angle, translation?): Transformation2d

Creates a rotation transformation around point by angle.

If translation is provided, it is assigned as the translation component.

Parameters

point

Point2d

Rotation point.

angle

number

Rotation angle.

translation?

Vector2d

Translation vector of the transformation.

Returns

Transformation2d

Properties

rotation

rotation: Matrix2d

Rotation matrix of the transformation.


scaleFactor

scaleFactor: number = 1

Scale factor of the transformation.


translation

translation: Vector2d

Translation vector of the transformation.

Methods

clone()

clone(): Transformation2d

Creates a new transformation with the same components as this transformation.

Returns

Transformation2d


copy()

copy(other): this

Copies the components of other to this transformation.

Parameters

other

Transformation2d

Transformation to copy.

Returns

this


invert()

invert(): this

Inverts this transformation.

Returns

this


inverted()

inverted(): Transformation2d

Returns a new transformation resulting from inverting this transformation.

Returns

Transformation2d


isEqual()

isEqual(other): boolean

Returns whether other is equal to this transformation.

Parameters

other

Transformation2d

Other transformation.

Returns

boolean


isIdentity()

isIdentity(): boolean

Returns whether this transformation is the identity transformation.

Returns

boolean


isNegative()

isNegative(): boolean

Returns whether the determinant of the rotation matrix is less than 0.

Returns

boolean


mirrorTransformation()

Call Signature

static mirrorTransformation(point): Transformation2d

Returns a mirror transformation about point.

Parameters

point

Point2d

Mirror point.

Returns

Transformation2d

Call Signature

static mirrorTransformation(axis): Transformation2d

Returns a mirror transformation about axis.

Parameters

axis

Axis2d

Mirror axis.

Returns

Transformation2d


multiplied()

multiplied(other): Transformation2d

Returns a new transformation resulting from multiplying this transformation by other.

Parameters

other

Transformation2d

Other transformation.

Returns

Transformation2d


multiply()

multiply(other): this

Multiplies this transformation by other.

Parameters

other

Transformation2d

Other transformation.

Returns

this


power()

power(num): this

Raises this transformation to the power num.

Parameters

num

number

Power value.

Returns

this


powered()

powered(num): Transformation2d

Returns a new transformation resulting from raising this transformation to the power num.

Parameters

num

number

Power value.

Returns

Transformation2d


resetToIdentity()

resetToIdentity(): this

Resets this transformation to the identity transformation.

Returns

this


rotateTransformation()

static rotateTransformation(point, angle): Transformation2d

Returns a rotation transformation around point by angle.

Parameters

point

Point2d

Rotation point.

angle

number

Rotation angle.

Returns

Transformation2d


rotationAngle()

rotationAngle(): number

Returns the rotation angle in radians.

Returns

number


scaleTransformation()

static scaleTransformation(point, scale): Transformation2d

Returns a scale transformation about point.

Parameters

point

Point2d

Reference point of the scaling transformation.

scale

number

Scale factor.

Returns

Transformation2d


setRotation()

Call Signature

setRotation(matrix): this

Sets the rotation matrix of the transformation.

Parameters

matrix

Matrix2d

Rotation matrix.

Returns

this

Call Signature

setRotation(point, angle): this

Sets the transformation as a rotation around point by angle.

Parameters

point

Point2d

Rotation point.

angle

number

Rotation angle.

Returns

this


setScaleFactor()

setScaleFactor(scaleFactor): this

Sets the scale factor of the transformation.

Parameters

scaleFactor

number

Scale factor.

Returns

this


setTranslation()

Call Signature

setTranslation(vector): this

Sets the translation vector of the transformation.

Parameters

vector

Vector2d

Translation vector.

Returns

this

Call Signature

setTranslation(point1, point2): this

Sets the translation vector of the transformation from point1 to point2.

Parameters

point1

Point2d

Start point of the translation vector.

point2

Point2d

End point of the translation vector.

Returns

this


translateTransformation()

static translateTransformation(vector): Transformation2d

Returns a translation transformation by vector.

Parameters

vector

Vector2d

Translation vector.

Returns

Transformation2d