Skip to content

Variable: Geometry

@kortexya/reasoninglayer


@kortexya/reasoninglayer / Geometry

const Geometry: object

Defined in: src/builders/value.ts:478

Builder namespace for the geometric shapes carried by Value.geometry.

Produces JSON using the "kind" discriminator (NOT "type"): {"kind": "Point2D", "x": 3, "y": 4}.

readonly boundingBox(x, y, width, height): BoundingBoxGeometry

Create an axis-aligned bounding box.

number

Left edge.

number

Top edge — the origin is top-left, as in image coordinates.

number

Width.

number

Height.

BoundingBoxGeometry

A BoundingBoxGeometry.

Serialization format: Tagged by "kind" (GeometryDto).

Geometry.boundingBox(10, 20, 100, 50)

readonly circle(centerX, centerY, radius): CircleGeometry

Create a circle.

number

Centre, horizontal.

number

Centre, vertical.

number

Radius.

CircleGeometry

A CircleGeometry.

Serialization format: Tagged by "kind" (GeometryDto).

Geometry.circle(50, 50, 12.5)

readonly point(x, y): Point2DGeometry

Create a point in the plane.

number

Horizontal coordinate.

number

Vertical coordinate.

Point2DGeometry

A Point2DGeometry: {"kind": "Point2D", "x": 3, "y": 4}.

Serialization format: Tagged by "kind" (GeometryDto).

Geometry.point(3, 4)

readonly polygon(points): PolygonGeometry

Create a polygon from an ordered ring of vertices.

[number, number][]

The vertices, each an [x, y] pair.

PolygonGeometry

A PolygonGeometry.

If a vertex is not a pair of numbers.

Serialization format: Tagged by "kind" (GeometryDto).

The ring is implicitly closed — do not repeat the first vertex last.

Geometry.polygon([[0, 0], [10, 0], [10, 8], [0, 8]])

Discriminator field is "kind", NOT "type" — the same convention as FuzzyShape, and for the same reason: type is taken by the enclosing tagged value.

import { Geometry, Value } from '@kortexya/reasoninglayer';
const footprint = Value.geometry(Geometry.polygon([[0, 0], [10, 0], [10, 8], [0, 8]]));