opensolid/geometry/3.0.1

NOTE: this package is not compatible with Elm 0.19.1

BoundingBox2d

BoundingBox2d

A BoundingBox2d is a rectangular box in 2D defined by its minimum and maximum X and Y values. It is possible to generate bounding boxes for most geometric objects; for example, Triangle2d.boundingBox takes a Triangle2d and returns a BoundingBox2d that contains that triangle. There are several use cases where it is more efficient to deal with the bounding box of an object than the object itself, such as:

  • Intersection checking: If (for example) the bounding boxes of a line segment and a triangle do not overlap, then the line segment and triangle cannot possibly intersect each other. Expensive intersection checking therefore only has to be performed for line segments and triangles whose bounding boxes do overlap.
  • 2D rendering: When rendering a 2D scene, any object whose bounding box does not overlap the viewing area must itself be completely outside the viewing area, and therefore does not have to be drawn. This provides a simple form of culling.
type alias BoundingBox2d =
BoundingBox2d

Constructors

{ minX : Float
, maxX : Float
, minY : Float
, maxY : Float
}
-> BoundingBox2d
singleton : Point2d -> BoundingBox2d
from : Point2d -> Point2d -> BoundingBox2d
hull : BoundingBox2d -> BoundingBox2d -> BoundingBox2d
intersection : BoundingBox2d -> BoundingBox2d -> Maybe BoundingBox2d
aggregate : List BoundingBox2d -> Maybe BoundingBox2d
containingPoints : List Point2d -> Maybe BoundingBox2d

Properties

BoundingBox2d
-> { minX : Float
, maxX : Float
, minY : Float
, maxY : Float
}
minX : BoundingBox2d -> Float
maxX : BoundingBox2d -> Float
minY : BoundingBox2d -> Float
maxY : BoundingBox2d -> Float
dimensions : BoundingBox2d -> ( Float, Float )
midX : BoundingBox2d -> Float
midY : BoundingBox2d -> Float
centroid : BoundingBox2d -> Point2d

Queries

contains : Point2d -> BoundingBox2d -> Bool
isContainedIn : BoundingBox2d -> BoundingBox2d -> Bool
intersects : BoundingBox2d -> BoundingBox2d -> Bool
overlappingBy : Order -> Float -> BoundingBox2d -> BoundingBox2d -> Bool
separatedBy : Order -> Float -> BoundingBox2d -> BoundingBox2d -> Bool

Transformations

scaleAbout : Point2d -> Float -> BoundingBox2d -> BoundingBox2d
translateBy : Vector2d -> BoundingBox2d -> BoundingBox2d
translateIn : Direction2d -> Float -> BoundingBox2d -> BoundingBox2d