API referenceGeometry
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
| Property | Type |
|---|---|
center | Vec2 |
radius | number |
Surface
type Surface = object;Defined in: bear/geometry/shapes.ts:12
Properties
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
| Parameter | Type | Description |
|---|---|---|
b | Boundary | The boundary polygon |
Returns
object
the width and height of the bounding box
| Name | Type |
|---|---|
height | number |
width | number |
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
b | Boundary | undefined | The boundary that should be a rectangle |
eps? | number | 1e-4 | How 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)
| Name | Type |
|---|---|
height | number |
width | number |