Last updated

API / geotoolkit / util / Transformation / Transformation

Class: Transformation

util.Transformation.Transformation

Create transformation matrix

Table of contents

Constructors
[new Transformation()](/solutions/geotoolkit/apis/classes/geotoolkit.util.transformation.transformation.md#new transformation())[new Transformation(properties)](/solutions/geotoolkit/apis/classes/geotoolkit.util.transformation.transformation.md#new transformation(properties))[new Transformation(tr)](/solutions/geotoolkit/apis/classes/geotoolkit.util.transformation.transformation.md#new transformation(tr))
[new Transformation(xx, yx, xy, yy, dx, dy)](/solutions/geotoolkit/apis/classes/geotoolkit.util.transformation.transformation.md#new transformation(xx, yx, xy, yy, dx, dy))
Methods
Css Properties
Name Type Description
dxnumberX axis translation
dynumberY axis translation
xxnumberX scale
xynumberXy skew
yxnumberYx skew
yynumberY scale

Contents

Constructors

new Transformation()

new Transformation()

Creates identity matrix


new Transformation(properties)

new Transformation(properties)

Parameters

Name Type Description
propertiesPropertiesobject to copy

new Transformation(tr)

new Transformation(tr)

Parameters

Name Type Description
trTransformationTransformation instance to copy

new Transformation(xx, yx, xy, yy, dx, dy)

new Transformation(xx, yx, xy, yy, dx, dy)

Parameters

Name Type Description
xxnumberx scale
yxnumberyx skew
xynumberxy skew
yynumbery scale
dxnumberx axis translation
dynumbery axis translation
Methods

clone

clone(): Transformation

Return clone object.

Returns

Transformation

a copy of this transformation


concatenate

concatenate(Tx): Transformation

Concatenates Tx to transformation

Parameters

Name Type Description
TxTransformationtransformation

Returns

Transformation

this


createInverse

createInverse(): Transformation

Create inverse transformation

Returns

Transformation


fastEquals

fastEquals(Tx): boolean

Return true if transformation are identical

Parameters

Name Type Description
TxTransformationtransformation

Returns

boolean


getAngle

getAngle(): number

Gets rotation angle Note: only for transformation without skewing

Returns

number

rotation angle


getClassName

getClassName(): string

Returns

string


getDeterminant

getDeterminant(): number

Returns matrix determinant

Returns

number


getLengthToXRatioAt

getLengthToXRatioAt(): number

Return length to X ratio

Returns

number


getLengthToYRatioAt

getLengthToYRatioAt(): number

Return length to Y ratio

Returns

number


getProperties

getProperties(): Properties

Gets all the properties pertaining to this object

Returns

Properties

An object containing the properties to set


getScaleX

getScaleX(): number

Returns X Scale(xx)

Returns

number


getScaleY

getScaleY(): number

Returns Y Scale(yy)

Returns

number


getShearX

getShearX(): number

Returns X sheer (xy)

Returns

number


getShearY

getShearY(): number

Returns Y sheer (yx)

Returns

number


getTranslate

getTranslate(): Point

Returns translation in both X & Y (dx, dy)

Returns

Point


getTranslateX

getTranslateX(): number

Returns X translation (dx)

Returns

number


getTranslateY

getTranslateY(): number

Returns Y translation (dy)

Returns

number


inverseTransform

inverseTransform<T>(source, destination?): T

Performs an inverse transform using points, rect or dimension

Type parameters

NameType
Textends Point | Rect | Dimension

Parameters

Name Type Description
sourceTsource rect
Optional destinationTdestination rect

Returns

T

transformation from source to destination


inverseTransformDimension

inverseTransformDimension(sourceSize, targetSize?): Dimension

Inverse transforms the specified dimension

Parameters

Name Type Description
sourceSizeDimensionthe point to be inverse transformed
Optional targetSizeDimensionthe size to hold the transformed point

Returns

Dimension

the result of the inverse transform.


inverseTransformPoint

inverseTransformPoint(sourcePoint, destinationPoint?): Point

Inverse transforms the specified point

Parameters

Name Type Description
sourcePointPointsource point to transform
Optional destinationPointPointoptional destination point

Returns

Point

the result of the inverse transform.


inverseTransformRect

inverseTransformRect(source, destination?): Rect

Inverse transform rectangle

Parameters

Name Type Description
sourceRectsource rectangle
Optional destinationRectdestination rectangle

Returns

Rect

the transformed rect


inverseTransformXY

inverseTransformXY(x, y): Point

Inverse transform point defined by two coordinates X and Y

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

Point


isIdentity

isIdentity(): boolean

Is identity transformation

Returns

boolean

is this identity transformation.


isRotated

isRotated(): boolean

Is rotated transformation

Returns

boolean

rotation flag


preConcatenate

preConcatenate(Tx): Transformation

Pre-concatenates transformation matrix with Tx

Parameters

Name Type Description
TxTransformationtransformation

Returns

Transformation

this


rotate

rotate(theta): Transformation

Rotate

Parameters

Name Type Description
thetanumberangle to rotate

Returns

Transformation

this


scale

scale(sx, sy): Transformation

Scale

Parameters

Name Type Description
sxnumberscale factor along x coordinate
synumberscale factor along y coordinate

Returns

Transformation

this


setPointsToPointsTransformation

setPointsToPointsTransformation(src1, src2, src3, dst1, dst2, dst3): Transformation

Sets transformation based on three (source => destination) point pairs

Throws

Error if determinant === 0

Parameters

Name Type Description
src1Pointfirst source point
src2Pointsecond source point
src3Pointthird source point
dst1Pointfirst destination point
dst2Pointsecond destination point
dst3Pointthird destination point

Returns

Transformation

this


setProperties

setProperties(properties?): Transformation

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesPropertiesAn object containing the properties to set

Returns

Transformation

this


setRectToRectTransformation

setRectToRectTransformation(source, destination, horizontalFlip?, verticalFlip?, aspectRatio?): Transformation

Sets rect to rect transformation

Throws

if illegal source or destination rectangle

Parameters

Name Type Description
sourceRectsource rectangle
destinationRectdestination rectangle
Optional horizontalFlipbooleanhorizontal flip
Optional verticalFlipbooleanvertical flip
Optional aspectRatiobooleankeeps aspect ratio

Returns

Transformation

this


setScale

setScale(xx, yy): Transformation

Sets X & Y Scale by xx and yy

Parameters

Name Type Description
xxnumberx scale
yynumbery scale

Returns

Transformation

this


setToIdentity

setToIdentity(): Transformation

Resets this transform to the Identity transform.

Returns

Transformation

this


setTransformation

setTransformation(xx): Transformation

Sets transformation

Parameters

Name Type Description
xxTransformationTransformation

Returns

Transformation

this

setTransformation(xx, yx, xy, yy, dx, dy): Transformation

Sets transformation

Parameters

Name Type Description
xxnumberx scale
yxnumberyx skew
xynumberxy skew
yynumbery scale
dxnumberx axis translation
dynumbery axis translation

Returns

Transformation

this


setTranslate

setTranslate(dx, dy): Transformation

Sets X & Y translation by dx and dy

Parameters

Name Type Description
dxnumberx offset
dynumbery offset

Returns

Transformation

this


shear

shear(shx, shy): Transformation

Applies a shear mapping to the transform

Parameters

Name Type Description
shxnumbershear coefficient along x coordinate
shynumbershear coefficient along y coordinate

Returns

Transformation

this


toString

toString(): string

Returns transformation parameters as one string

Returns

string


transform

transform<T>(source, destination?): T

Transforms from one point, rect, or dimension to another

Type parameters

NameType
Textends Point | Rect | GraphicsPath | Dimension

Parameters

Name Type Description
sourceTorigin to be transformed from
Optional destinationTdestination rectangle

Returns

T

transformation from source to destination

transform(x, y): Point

Transform point defined by two coordinates X and Y

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

Point


transformDimension

transformDimension(sourceSize, targetSize?): Dimension

Inverse transforms the specified dimension

Parameters

Name Type Description
sourceSizeTextMetrics | Dimensionthe point to be inverse transformed
Optional targetSizeDimensionthe size to hold the transformed point

Returns

Dimension

the result of the transform.


transformPath

transformPath(srcPath, dstPath?): GraphicsPath

Transforms GraphicsPath

Parameters

Name Type Description
srcPathGraphicsPathsource path to transform
Optional dstPathGraphicsPathtransformed path

Returns

GraphicsPath

transformed path


transformPoint

transformPoint(src, dst?): Point

Transform point

Parameters

Name Type Description
srcPointsource point to transform
Optional dstPointoptional returned transformed point

Returns

Point

the transformed point


transformPoints

transformPoints(x, y, count): void

Transform a set of point defined by two arrays

Parameters

Name Type Description
xnumber[]an array of x-coordinates
ynumber[]an array of y-coordinates
countnumbera count of point to transform

Returns

void


transformPolygon

transformPolygon(source, destination?): Polygon

Transform polygon

Parameters

Name Type Description
sourcePolygonsource polygon
Optional destinationPolygondestination polygon

Returns

Polygon


transformRect

transformRect(source, destination?): Rect

Transform rectangle

Throws

if destination is readonly mode

Parameters

Name Type Description
sourceRectsource rectangle
Optional destinationRectdestination rectangle

Returns

Rect


transformX

transformX(x, y): number

Apply X transformation to x,y

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

number


transformXY

transformXY(x, y): Point

Transform point defined by two coordinates X and Y

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

Point


transformY

transformY(x, y): number

Apply Y transformation to x,y

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate

Returns

number


translate

translate(tx, ty): Transformation

Translate

Parameters

Name Type Description
txnumberx offset along x coordinate
tynumbery offset along y coordinate

Returns

Transformation

this


canCreatePointsToPointsInstance

Static canCreatePointsToPointsInstance(src1, src2, src3): boolean

Returns true if transformation can be created from provided source points

Parameters

Name Type Description
src1Pointfirst source point
src2Pointsecond source point
src3Pointthird source point

Returns

boolean


canCreateRectToRectInstance

Static canCreateRectToRectInstance(source, destination): boolean

Return true if transformation can be created from source rectangle to destination rectangle. Vertical or horizontal dimension can be empty

Parameters

Name Type Description
sourceRectsource rectangle
destinationRectdestination rectangle

Returns

boolean


divide

Static divide(a, b, dst?): Transformation

Divide two matrices

Parameters

Name Type Description
aTransformationthe first matrix
bTransformationthe second matrix
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


getClassName

Static getClassName(): string

Returns

string


getPointsToPointsInstance

Static getPointsToPointsInstance(src1, src2, src3, dst1, dst2, dst3, destination?): Transformation

Returns transformation based on three (source => destination) point pairs

Parameters

Name Type Description
src1Pointfirst source point
src2Pointsecond source point
src3Pointthird source point
dst1Pointfirst destination point
dst2Pointsecond destination point
dst3Pointthird destination point
Optional destinationTransformationdestination transformation object

Returns

Transformation


getRectToRectInstance

Static getRectToRectInstance(source, destination, horizontalFlip?, verticalFlip?, aspectRatio?, dst?): Transformation

Gets rect to rect transformation

Throws

Error if source or destination is null

Parameters

Name Type Description
sourceRectsource rectangle
destinationRectdestination rectangle
Optional horizontalFlipbooleanhorizontal flip
Optional verticalFlipbooleanvertical flip
Optional aspectRatiobooleankeeps aspect ratio
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


getRotateInstance

Static getRotateInstance(theta, x, y, dst?): Transformation

Gets rotate instance

Throws

Error if x, y or theta is null

Parameters

Name Type Description
thetanumberangle
xnumberx coordinate
ynumbery coordinate
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


getScaleInstance

Static getScaleInstance(scaleX, scaleY, dst?): Transformation

Get a new transformation instance based on scale values

Throws

Error if scaleX or scaleY is null

Parameters

Name Type Description
scaleXnumberscale factor along x coordinate
scaleYnumberscale factor along y coordinate
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


getSegmentToSegmentInstance

Static getSegmentToSegmentInstance(from1, from2, to1, to2, dst?): Transformation

Gets segment to segment transformation

Throws

Error if source or destination is null

Parameters

Name Type Description
from1Pointfirst source segment point
from2Pointsecond source segment point
to1Pointfirst destination segment point
to2Pointsecond destination segment point
Optional dstTransformationdestination transformation object

Returns

Transformation

transformation that transforms point from1 => to1, and from2 => to2


getShearInstance

Static getShearInstance(shx, shy, dst?): Transformation

Get a new transformation instance based on shear values

Throws

Error if shx or shy is null

Parameters

Name Type Description
shxnumbershear coefficient along x coordinate
shynumbershear coefficient along y coordinate
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


getTranslateInstance

Static getTranslateInstance(x, y, dst?): Transformation

Gets translate instance

Throws

Error if x or y is null

Parameters

Name Type Description
xnumberx coordinate
ynumbery coordinate
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation


multiply

Static multiply(a, b, dst?): Transformation

Multiply two matrices

Parameters

Name Type Description
aTransformationthe first matrix
bTransformationthe second matrix
Optional dstTransformationdestination transformation object

Returns

Transformation

new transformation