class Geometry · Computations

Fits

Computes the pin that fits one shape into another (a box or circle into a box or circle).

Each method returns a pin encoding a similarity transform (translation, uniform scale, and rotation) that maps the source shape into the target shape. The source is centered within the target and scaled uniformly so that it fits inside without exceeding the target's bounds.

Static methods

boxInBoxstatic

static boxInBox(source: Box | ShapeLike, target: Box | ShapeLike, result?: Pin | null): Pin

Computes the transform that fits a box inside another box.

source
The box to fit.
target
The box that source is fitted into.
result optional
Optional Pin to write the result into; it is returned. Without it, a new Pin is returned.

Returns A pin encoding the translation and uniform scale that maps source centered inside target.

boxInCirclestatic

static boxInCircle(source: Box | ShapeLike, target: Circle | ShapeLike, result?: Pin | null): Pin

Computes the transform that fits a box inside a circle.

source
The box to fit.
target
The circle that source is fitted into.
result optional
Optional Pin to write the result into; it is returned. Without it, a new Pin is returned.

Returns A pin encoding the translation and uniform scale that maps source centered inside target, scaled so its diagonal equals the circle's diameter.

circleInBoxstatic

static circleInBox(source: Circle | ShapeLike, target: Box | ShapeLike, result?: Pin | null): Pin

Computes the transform that fits a circle inside a box.

source
The circle to fit.
target
The box that source is fitted into.
result optional
Optional Pin to write the result into; it is returned. Without it, a new Pin is returned.

Returns A pin encoding the translation and uniform scale that maps source centered inside target, scaled so its diameter equals the box's shorter side.

circleInCirclestatic

static circleInCircle(source: Circle | ShapeLike, target: Circle | ShapeLike, result?: Pin | null): Pin

Computes the transform that fits a circle inside another circle.

source
The circle to fit.
target
The circle that source is fitted into.
result optional
Optional Pin to write the result into; it is returned. Without it, a new Pin is returned.

Returns A pin encoding the translation and uniform scale that maps source centered inside target, scaled so their radii match.