Skip to content

@technobuddha > library > Geometry > Polygon

Function: translate()

Translate a point or polygon by a specified amount.

Call Signature

ts
function translate(point: Cartesian, amount: XY): Cartesian;

Defined in: translate.ts:24

Translate a point by a specified amount.

Parameters

ParameterTypeDescription
pointCartesianThe point or array of points to translate.
amountXYThe amount to move the point by.

Returns

Cartesian

The translated point.

Example

typescript
translate({ x: 1, y: 0 }t, { x: 1, y: 2 }); // { x: 2, y: 2 }

Call Signature

ts
function translate(polygon: Polygon, amount: Cartesian): Polygon;

Defined in: src/translate.ts:39

Translate a polygon by a specified amount.

Parameters

ParameterTypeDescription
polygonPolygonThe polygon to translate.
amountCartesianThe amount to move the polygon by.

Returns

Polygon

The translated polygon.

Example

typescript
translate([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 0, y: 1}], { x: 1, y: 2 });
// [{ x: 1, y: 2 }, { x: 2, y: 3 }, { x: 1, y: 3 }]