polygon2.minkowskiSum

The Minkowski sum a ⊕ b: every point of a plus every point of b, for convex or non-convex rings.

GeometricSince 0.4.0

Usage

TypeScript
Polygon2.minkowskiSum(a: Polygon2, b: Polygon2): Result<Region2>

Parameters

  • aPolygon2

    First operand, one ring of either orientation. Required. In model.

  • bPolygon2

    Second operand, one ring of either orientation. Required. In model.

Returns

Ok with the sum as a region (a non-convex sum can have holes).

Errors

Guarantees

  • for axis-aligned squares of sides s and t, area = (s + t)² (Region2.area)
  • contains every corner of a plus every corner of b, up to the edge rule (Region2.contains)
  • outlines wind counter-clockwise and holes clockwise (part.outer.isCounterClockwise(), !hole.isCounterClockwise())
  • The same result on every machine.

Example

TypeScript
const r = Polygon2.minkowskiSum(Polygon2.rectangle(2, 2).value, Polygon2.rectangle(1, 1).value) // → area 9 once loadGeometryKernel() has run

See also