Math.Geometry


BoundingBox2D Module

Functions and values

Function or value Description

aggregate first rest

Full Usage: aggregate first rest

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Find the bounding box containing one or more input boxes; works much like [`hull`](#hull). See also [`aggregateN`](#aggregateN).

first : BoundingBox2D<'Units, 'Coordinates>
rest : BoundingBox2D<'Units, 'Coordinates> list
Returns: BoundingBox2D<'Units, 'Coordinates>

aggregate3 b1 b2 b3

Full Usage: aggregate3 b1 b2 b3

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Build a bounding box that contains all three of the given bounding boxes. This is equivalent to running `aggregate` with three points but is more efficient.

b1 : BoundingBox2D<'Units, 'Coordinates>
b2 : BoundingBox2D<'Units, 'Coordinates>
b3 : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

aggregateN boxes

Full Usage: aggregateN boxes

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates> option

Construct a bounding box containing all bounding boxes in the given list. If the list is empty, returns `Nothing`. If you know you have at least one bounding box, you can use [`aggregate`](#aggregate) instead.

boxes : BoundingBox2D<'Units, 'Coordinates> list
Returns: BoundingBox2D<'Units, 'Coordinates> option

aggregateOf getBoundingBox first rest

Full Usage: aggregateOf getBoundingBox first rest

Parameters:
    getBoundingBox : 'a -> BoundingBox2D<'Units, 'Coordinates>
    first : 'a
    rest : 'a list

Returns: BoundingBox2D<'Units, 'Coordinates>

Like [`aggregate`](#aggregate), but lets you work on any kind of item as long as a bounding box can be extracted from it.

getBoundingBox : 'a -> BoundingBox2D<'Units, 'Coordinates>
first : 'a
rest : 'a list
Returns: BoundingBox2D<'Units, 'Coordinates>

aggregateOfN getBoundingBox items

Full Usage: aggregateOfN getBoundingBox items

Parameters:
    getBoundingBox : 'a -> BoundingBox2D<'Units, 'Coordinates>
    items : 'a list

Returns: BoundingBox2D<'Units, 'Coordinates> option

Combination of [`aggregateOf`](#aggregateOf) and [`aggregateN`](#aggregateN).

getBoundingBox : 'a -> BoundingBox2D<'Units, 'Coordinates>
items : 'a list
Returns: BoundingBox2D<'Units, 'Coordinates> option

centerPoint box

Full Usage: centerPoint box

Parameters:
Returns: Point2D<'Units, 'Coordinates>
box : BoundingBox2D<'Units, 'Coordiantes>
Returns: Point2D<'Units, 'Coordinates>

containingPoint point box

Full Usage: containingPoint point box

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Get a bounding box that contains the new point. If the box does not contain the new point, the box will grow to fit the new point. If the point is within the box, the same bounding box is returned.

point : Point2D<'Units, 'Coordinates>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

containingPoints points box

Full Usage: containingPoints points box

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>
points : Point2D<'Units, 'Coordinates> list
box : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

contains target box

Full Usage: contains target box

Parameters:
Returns: bool

Test to see if the target bounding box is contained withing the bounding box

target : Point2D<'Units, 'Coordinates>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: bool

corners box

Full Usage: corners box

Parameters:
Returns: Point2D<'Units, 'Coordinates> list

Returned in clockwise order from top left rotating around clockwise

box : BoundingBox2D<'Units, 'Coordinates>
Returns: Point2D<'Units, 'Coordinates> list

dimensions boundingBox

Full Usage: dimensions boundingBox

Parameters:
Returns: Quantity<'Units> * Quantity<'Units>

Get the X and Y dimensions (width and height) of a bounding box.

boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units> * Quantity<'Units>

empty

Full Usage: empty

Returns: BoundingBox2D<'Units, 'Coordinates>

Creates an infinitely small bounding box. This can be used when growing a bounding box around objects

Returns: BoundingBox2D<'Units, 'Coordinates>

expandBy amount boundingBox

Full Usage: expandBy amount boundingBox

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Expand the given bounding box in all directions by the given offset: Negative offsets will be treated as positive (the absolute value will be used), so the resulting box will always be at least as large as the original. If you need to be able to contract a bounding box, use [`offsetBy`](BoundingBox2d#offsetBy) instead.

amount : Quantity<'Units>
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

from p1 p2

Full Usage: from p1 p2

Parameters:
    p1 : Point2D<'Units, 'Coordinates>
    p2 : Point2D<'Units, 'Coordinates>

Returns: BoundingBox2D<'Units, 'c>

Create a bounding box that contains the two points

p1 : Point2D<'Units, 'Coordinates>
p2 : Point2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'c>

fromExtrema given

Full Usage: fromExtrema given

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

If the minimum and maximum values are provided in the wrong order (for example if `minX` is greater than `maxX`), then they will be swapped so that the resulting bounding box is valid.

given : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

height box

Full Usage: height box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

hull first rest

Full Usage: hull first rest

Parameters:
    first : Point2D<'Units, 'Coordinates>
    rest : Point2D<'Units, 'Coordinates> list

Returns: BoundingBox2D<'Units, 'Coordinates>

Find the bounding box containing one or more input points. Often ends up being used within a match expression. See also [`hullN`](#hullN).

first : Point2D<'Units, 'Coordinates>
rest : Point2D<'Units, 'Coordinates> list
Returns: BoundingBox2D<'Units, 'Coordinates>

hull3 firstPoint secondPoint thirdPoint

Full Usage: hull3 firstPoint secondPoint thirdPoint

Parameters:
    firstPoint : Point2D<'Units, 'Coordiantes>
    secondPoint : Point2D<'Units, 'Coordinates>
    thirdPoint : Point2D<'Units, 'Coordinates>

Returns: BoundingBox2D<'Units, 'Coordinates>

Build a bounding box that contains all three of the given points. This is equivalent to calling `hull` on three points but is more efficient.

firstPoint : Point2D<'Units, 'Coordiantes>
secondPoint : Point2D<'Units, 'Coordinates>
thirdPoint : Point2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

hullN points

Full Usage: hullN points

Parameters:
    points : Point2D<'Units, 'Coordinates> list

Returns: BoundingBox2D<'Units, 'Coordinates> option

Construct a bounding box containing all _N_ points in the given list. If the list is empty, returns `Nothing`. If you know you have at least one point, you can use [`hull`](#hull) instead.

points : Point2D<'Units, 'Coordinates> list
Returns: BoundingBox2D<'Units, 'Coordinates> option

hullOf getPoint first rest

Full Usage: hullOf getPoint first rest

Parameters:
    getPoint : 'a -> Point2D<'Units, 'Coordinates>
    first : 'a
    rest : 'a list

Returns: BoundingBox2D<'Units, 'Coordinates>

Like [`hull`](#hull), but lets you work on any kind of item as long as a point can be extracted from it. For example, if you had

getPoint : 'a -> Point2D<'Units, 'Coordinates>
first : 'a
rest : 'a list
Returns: BoundingBox2D<'Units, 'Coordinates>

hullOfN getBoundingBox items

Full Usage: hullOfN getBoundingBox items

Parameters:
    getBoundingBox : 'a -> Point2D<'Units, 'Coordinates>
    items : 'a list

Returns: BoundingBox2D<'Units, 'Coordinates> option

Combination of [`hullOf`](#hullOf) and [`hullN`](#hullN).

getBoundingBox : 'a -> Point2D<'Units, 'Coordinates>
items : 'a list
Returns: BoundingBox2D<'Units, 'Coordinates> option

intersection first second

Full Usage: intersection first second

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates> option

Attempt to build a bounding box that contains all points common to both given bounding boxes. If the given boxes do not intersect, returns `Nothing`. If two boxes just touch along an edge or at a corner, they are still considered to have an intersection, even though that intersection will have zero area (at least one of its dimensions will be zero).

first : BoundingBox2D<'Units, 'Coordinates>
second : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates> option

intersects first second

Full Usage: intersects first second

Parameters:
Returns: bool
first : BoundingBox2D<'Units, 'Coordinates>
second : BoundingBox2D<'Units, 'Coordinates>
Returns: bool

isContainedIn target box

Full Usage: isContainedIn target box

Parameters:
Returns: bool

Test to see if the target bounding box is contained withing the bounding box

target : BoundingBox2D<'Units, 'Coordinates>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: bool

lineSegments box

Full Usage: lineSegments box

Parameters:
Returns: LineSegment2D<'Units, 'Coordinates> list

Get the four line segments surrounding the bounding box. The lines are created from the top left point, creating line segments around the bounding box clockwise.

box : BoundingBox2D<'Units, 'Coordinates>
Returns: LineSegment2D<'Units, 'Coordinates> list

maxX box

Full Usage: maxX box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

maxY box

Full Usage: maxY box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

midX box

Full Usage: midX box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordiantes>
Returns: Quantity<'Units>

midY box

Full Usage: midY box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordiantes>
Returns: Quantity<'Units>

minX box

Full Usage: minX box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

minY box

Full Usage: minY box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

offsetBy amount boundingBox

Full Usage: offsetBy amount boundingBox

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates> option

Expand or shrink the given bounding box in all the directions by the given distance. A positive offset will cause the bounding box to expand and a negative value will cause it to shrink. Returns `None` if the offset is negative and large enough to cause the bounding box to vanish (that is, if the offset is larger than half the height or half the width of the bounding box, whichever is less). If you only want to expand a bounding box, you can use [`expandBy`](BoundingBox2d#expandBy) instead (which does not return an `Option`).

amount : Quantity<'Units>
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates> option

overlappingByAtLeast tolerance firstBox secondBox

Full Usage: overlappingByAtLeast tolerance firstBox secondBox

Parameters:
Returns: bool

Check two boxes overlap by at least the given amount. For example, you could implement a tolerant collision check (one that only returns true if the boxes overlap by at least a millimeter, and ignores boxes that just barely touch each other). Overlap is defined as the _minimum_ distance one box would have to move so that it did not touch the other. Boxes that just touch are considered to have an overlap of zero.

tolerance : Quantity<'Units>
firstBox : BoundingBox2D<'Units, 'Coordinates>
secondBox : BoundingBox2D<'Units, 'Coordinates>
Returns: bool

scaleAbout point scale boundingBox

Full Usage: scaleAbout point scale boundingBox

Parameters:
    point : Point2D<'Units, 'Coordinates>
    scale : float
    boundingBox : BoundingBox2D<'Units, 'Coordinates>

Returns: BoundingBox2D<'Units, 'Coordinates>

Scale a bounding box about a given point by a given scale.

point : Point2D<'Units, 'Coordinates>
scale : float
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

separatedByAtLeast tolerance firstBox secondBox

Full Usage: separatedByAtLeast tolerance firstBox secondBox

Parameters:
Returns: bool

Check if two boxes are separated by at least the given amount. For example, to perform clash detection between some objects, you could use `separatedBy` on those objects' bounding boxes as a quick check to see if the objects had a gap of at least 1 cm between them. Separation is defined as the _minimum_ distance one box would have to move so that it touched the other. (Note that this may be a _diagonal_ distance between corners.) Boxes that just touch are considered to have a separation of zero. will return true even if the two boxes just touch each other.

tolerance : Quantity<'Units>
firstBox : BoundingBox2D<'Units, 'Coordinates>
secondBox : BoundingBox2D<'Units, 'Coordinates>
Returns: bool

singleton p

Full Usage: singleton p

Parameters:
    p : Point2D<'Units, 'Coordinastes>

Returns: BoundingBox2D<'Units, 'Coordinates>
p : Point2D<'Units, 'Coordinastes>
Returns: BoundingBox2D<'Units, 'Coordinates>

translateBy displacement boundingBox

Full Usage: translateBy displacement boundingBox

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Translate a bounding box by a given displacement.

displacement : Vector2D<'Units, 'Coordinates>
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

translateIn direction distance boundingBox

Full Usage: translateIn direction distance boundingBox

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Translate a bounding box in a given direction by a given distance.

direction : Direction2D<'Coordinates>
distance : Quantity<'Units>
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

union first second

Full Usage: union first second

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Create a bounding box that contains both bounding boxes.

first : BoundingBox2D<'Units, 'Coordinates>
second : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

unsafeOffsetBy amount boundingBox

Full Usage: unsafeOffsetBy amount boundingBox

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>

Offsets boundingBox irrespective of the resulting bounding box is valid or not.

amount : Quantity<'Units>
boundingBox : BoundingBox2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>

width box

Full Usage: width box

Parameters:
Returns: Quantity<'Units>
box : BoundingBox2D<'Units, 'Coordinates>
Returns: Quantity<'Units>

withDimensions (givenWidth, givenHeight) givenCenterPoint

Full Usage: withDimensions (givenWidth, givenHeight) givenCenterPoint

Parameters:
Returns: BoundingBox2D<'Units, 'Coordinates>
givenWidth : Quantity<'Units>
givenHeight : Quantity<'Units>
givenCenterPoint : Point2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates>