# Transform

## Content

# Class: Transform

Represents a 3x2 transformation matrix.

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### id

#### Get Signature

```ts
get id(): number;
```

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### matrix

#### Get Signature

```ts
get matrix(): number[];
```

Gets or sets the transformation matrix.
The matrix consists of six numbers (their meaning is simplified for clarity):
m11 - scales the drawing horizontally
m12 - skew the the drawing horizontally
m21 - skew the the drawing vertically
m22 - scales the drawing vertically
m31 - moves the the drawing horizontally
m32 - moves the the drawing vertically

##### Returns

`number`[]

#### Set Signature

```ts
set matrix(matrix): void;
```

Gets or sets the transformation matrix.
The matrix consists of six numbers (their meaning is simplified for clarity):
m11 - scales the drawing horizontally
m12 - skew the the drawing horizontally
m21 - skew the the drawing vertically
m22 - scales the drawing vertically
m31 - moves the the drawing horizontally
m32 - moves the the drawing vertically

##### Parameters

###### matrix

`number`[]

##### Returns

`void`

***

### om

#### Get Signature

```ts
get om(): ObjectManager;
```

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

## Methods

### createIdentity()

#### Call Signature

```ts
static createIdentity(): Transform;
```

Creates an identity transformation.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createIdentity(om): Transform;
```

Creates an identity transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

##### Returns

`Transform`

A new instance of Transform.

***

### createMatrix()

#### Call Signature

```ts
static createMatrix(
   m11, 
   m12, 
   m21, 
   m22, 
   m31, 
   m32): Transform;
```

Creates a transformation based on the specified 3x2 matrix.

##### Parameters

###### m11

`number`

Scales the drawing horizontally

###### m12

`number`

Skew the the drawing horizontally

###### m21

`number`

Skew the the drawing vertically

###### m22

`number`

Scales the drawing vertically

###### m31

`number`

Moves the the drawing horizontally

###### m32

`number`

Moves the the drawing vertically

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createMatrix(
   om, 
   m11, 
   m12, 
   m21, 
   m22, 
   m31, 
   m32): Transform;
```

Creates a transformation based on the specified 3x2 matrix.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### m11

`number`

Scales the drawing horizontally

###### m12

`number`

Skew the the drawing horizontally

###### m21

`number`

Skew the the drawing vertically

###### m22

`number`

Scales the drawing vertically

###### m31

`number`

Moves the the drawing horizontally

###### m32

`number`

Moves the the drawing vertically

##### Returns

`Transform`

A new instance of Transform.

***

### createRotation()

#### Call Signature

```ts
static createRotation(
   angle, 
   angleUnits?, 
   cx?, 
   cy?): Transform;
```

Creates a rotation transformation.

##### Parameters

###### angle

`number`

The rotation angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createRotation(
   om, 
   angle, 
   angleUnits?, 
   cx?, 
   cy?): Transform;
```

Creates a rotation transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### angle

`number`

The rotation angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createScale()

#### Call Signature

```ts
static createScale(
   scaleFactor, 
   cx?, 
   cy?): Transform;
```

Creates a scaling transformation.

##### Parameters

###### scaleFactor

`number`

The value to scale by on the X and Y axes.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createScale(
   om, 
   scaleFactor, 
   cx?, 
   cy?): Transform;
```

Creates a scaling transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### scaleFactor

`number`

The value to scale by on the X and Y axes.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createScaleXY()

#### Call Signature

```ts
static createScaleXY(
   scaleX, 
   scaleY, 
   cx?, 
   cy?): Transform;
```

Creates a scaling transformation.

##### Parameters

###### scaleX

`number`

The value to scale by on the X axis.

###### scaleY

`number`

The value to scale by on the Y axis.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createScaleXY(
   om, 
   scaleX, 
   scaleY, 
   cx?, 
   cy?): Transform;
```

Creates a scaling transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### scaleX

`number`

The value to scale by on the X axis.

###### scaleY

`number`

The value to scale by on the Y axis.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createSkew()

#### Call Signature

```ts
static createSkew(
   angleX, 
   angleY, 
   angleUnits?, 
   cx?, 
   cy?): Transform;
```

Creates a skew transformation.

##### Parameters

###### angleX

`number`

The X angle.

###### angleY

`number`

The Y angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createSkew(
   om, 
   angleX, 
   angleY, 
   angleUnits?, 
   cx?, 
   cy?): Transform;
```

Creates a skew transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### angleX

`number`

The X angle.

###### angleY

`number`

The Y angle.

###### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

###### cx?

`number`

The optional center point X offset.

###### cy?

`number`

The optional center point Y offset.

##### Returns

`Transform`

A new instance of Transform.

***

### createTranslation()

#### Call Signature

```ts
static createTranslation(offsetX, offsetY): Transform;
```

Creates a translation transformation.

##### Parameters

###### offsetX

`number`

The horizontal offset.

###### offsetY

`number`

The vertical offset.

##### Returns

`Transform`

A new instance of Transform.

#### Call Signature

```ts
static createTranslation(
   om, 
   offsetX, 
   offsetY): Transform;
```

Creates a translation transformation.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Transform object.

###### offsetX

`number`

The horizontal offset.

###### offsetY

`number`

The vertical offset.

##### Returns

`Transform`

A new instance of Transform.

***

### applyTransform()

```ts
applyTransform(transform): void;
```

Applies the transformation to the current instance.

#### Parameters

##### transform

`Transform`

The Transform object to be multiplied by the current transformation matrix.

#### Returns

`void`

***

### clone()

```ts
clone(): Transform;
```

Creates a copy of the current transformation.

#### Returns

`Transform`

A copy of the current Transform object.

***

### free()

```ts
free(): void;
```

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### pop()

```ts
pop(): void;
```

Restores the previously pushed transformation from the stack.

#### Returns

`void`

***

### push()

```ts
push(): void;
```

Saves the current transformation to the stack.

#### Returns

`void`

***

### rebind()

```ts
rebind(omTo): void;
```

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### reset()

```ts
reset(): void;
```

Resets the transformation to the identity matrix.

#### Returns

`void`

***

### rotate()

```ts
rotate(
   angle, 
   angleUnits?, 
   cx?, 
   cy?): void;
```

Applies the rotation transformation.

#### Parameters

##### angle

`number`

The rotation angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### scale()

```ts
scale(
   scaleFactor, 
   cx?, 
   cy?): void;
```

Applies the scaling transformation.

#### Parameters

##### scaleFactor

`number`

The value to scale by on the X and Y axes.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### scaleXY()

```ts
scaleXY(
   scaleX, 
   scaleY, 
   cx?, 
   cy?): void;
```

Applies the scaling transformation.

#### Parameters

##### scaleX

`number`

The value to scale by on the X axis.

##### scaleY

`number`

The value to scale by on the Y axis.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### setTransform()

```ts
setTransform(transform): void;
```

Sets the transformation to the current instance.

#### Parameters

##### transform

`Transform`

The Transform object to replace the current transformation.

#### Returns

`void`

***

### skew()

```ts
skew(
   angleX, 
   angleY, 
   angleUnits?, 
   cx?, 
   cy?): void;
```

Applies the skew transformation.

#### Parameters

##### angleX

`number`

The X angle.

##### angleY

`number`

The Y angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

##### cx?

`number`

The optional center point X offset.

##### cy?

`number`

The optional center point Y offset.

#### Returns

`void`

***

### skewX()

```ts
skewX(angle, angleUnits?): void;
```

Applies the skew transformation along the X axis.

#### Parameters

##### angle

`number`

The X angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

#### Returns

`void`

***

### skewY()

```ts
skewY(angle, angleUnits?): void;
```

Applies the skew transformation along the Y axis.

#### Parameters

##### angle

`number`

The Y angle.

##### angleUnits?

[`AngleUnits`](../enumerations/AngleUnits)

The angle units. The default is Radians.

#### Returns

`void`

***

### transformPoint()

```ts
transformPoint(point): Point;
```

Transforms a [Point](../type-aliases/Point) by the transformation matrix.

#### Parameters

##### point

[`Point`](../type-aliases/Point)

The original [Point](../type-aliases/Point).

#### Returns

[`Point`](../type-aliases/Point)

The transformed [Point](../type-aliases/Point).

***

### transformPoints()

```ts
transformPoints(points): Point[];
```

Transforms an array of [Point](../type-aliases/Point)s by the transformation matrix.

#### Parameters

##### points

[`Point`](../type-aliases/Point)[]

The original array of [Point](../type-aliases/Point)s.

#### Returns

[`Point`](../type-aliases/Point)[]

The array of transformed [Point](../type-aliases/Point)s.

***

### transformQuadrilateral()

```ts
transformQuadrilateral(quad): Quadrilateral;
```

Transforms a [ds.Quadrilateral](../type-aliases/Quadrilateral) by the transformation matrix.

#### Parameters

##### quad

[`Quadrilateral`](../type-aliases/Quadrilateral)

The original [ds.Quadrilateral](../type-aliases/Quadrilateral).

#### Returns

[`Quadrilateral`](../type-aliases/Quadrilateral)

The transformed [ds.Quadrilateral](../type-aliases/Quadrilateral).

***

### translate()

```ts
translate(offsetX, offsetY): void;
```

Applies the translation transformation.

#### Parameters

##### offsetX

`number`

The horizontal offset.

##### offsetY

`number`

The vertical offset.

#### Returns

`void`

***

### tryInvert()

```ts
tryInvert(): boolean;
```

Inverts the transformation matrix, if possible.

#### Returns

`boolean`

true on success, false otherwise.
