Skip to Content
Bear documentation

shapes

Import from bear/geometry/shapes.

Type Aliases

Boundary

type Boundary = Vec2[];

Defined in: bear/geometry/shapes.ts:6


Hole

type Hole = object;

Defined in: bear/geometry/shapes.ts:7

Properties

PropertyType
centerVec2
radiusnumber

Surface

type Surface = object;

Defined in: bear/geometry/shapes.ts:12

Properties

PropertyType
boundaryBoundary
frameFrame3
holes?Record<string, Hole>

Functions

boundaryToBoundingBox()

function boundaryToBoundingBox(b): object;

Defined in: bear/geometry/shapes.ts:25

Computes the bounding box of any polygon boundary. Works with rectangles, trapezoids, and arbitrary polygons.

Parameters

ParameterTypeDescription
bBoundaryThe boundary polygon

Returns

object

the width and height of the bounding box

NameType
heightnumber
widthnumber

boundaryToRectangle()

function boundaryToRectangle(b, eps?): object;

Defined in: bear/geometry/shapes.ts:52

This is a HACKY function to allow us to move quicker before we have robust geometry slicing and dicing. Oftentimes our simple cases are just rectangles, so this function will take a polygon boundary and (after making sure that it's a recangle) will extract the width and height

Parameters

ParameterTypeDefault valueDescription
bBoundaryundefinedThe boundary that should be a rectangle
eps?number1e-4How much float jitter to tolerate in verifying that the boundary is a rectangle

Returns

object

the width and height of the rectangle (2d, can be projected onto a 3d frame)

NameType
heightnumber
widthnumber

On this page