Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
bounding_box
A lightweight library for handling 2D bounding boxes / bounding rectangles.
A minimum two-dimensional bounding box / bounding rectangle describes the extents of an entity (shape, point set, line, ...) or a collection thereof in x-y coordinates.
Bounding boxes are very useful in computational geometry. For example, if the bounding boxes of two entities don't intersect, the entities themselves also don't intersect. This property can be used to short-circuit intersection algorithms. In a similar fashion, they can be used as a first stage of an algorithm which checks if an entity contains a point.
Another use case is to find the minimum space required for displaying an entity on a rectangular monitor. By comparing the bounding box to the actually available monitor space, scaling factors can be obtained so the entire entity can be shown on the monitor at once.
This library offers a struct BoundingBox
and a trait ToBoundingBox
which can be used to obtain bounding boxes of types which implement it. The BoundingBox
type has various methods to e.g. calculate its dimensions, find its center, transform it, unite it with other BoundingBox
instances, find intersections between BoundingBox
instances and many more ...
The full API documentation is available at https://docs.rs/bounding_box/0.1.0/bounding_box/.
As an example, the following code snippet shows how a BoundingBox
can be used with a Circle
type:
use ;
let c1 = Circle ;
let c2 = Circle ;
let c3 = Circle ;
// ===============================================================
// Intersection
/// This is an incomplete example of an intersection algorithm
assert_eq!;
assert_eq!;
// ===============================================================
// Contains a point
/// This is an incomplete example of a containment check algorithm
assert_eq!;
assert_eq!;
// ===============================================================
// Find the common bounding box of all circles
// Using an iterator
let bb_common_iter = from_bounded_entities.expect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Alternatively, the bounding box could also be found by manually uniting the individual bounding boxes
let bb_common_man = c1.bounding_box.union;
assert_eq!;
The following code snippet shows how to find the smallest bounding box containing a given vertex set.
use BoundingBox;
let bb_all_pts = from_vertices.expect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Crate features
All features are disabled by default.
Serialization and deserialization
Bounding boxes can be serialized and deserialized using the serde crate.
This functionality is gated behind the serde feature flag.
Tolerances
Some methods of BoundingBox
are gated behind the approx feature flag. Enabling this flag adds
the approx crate as a dependency. The gated methods are prefixed with approx_
and are variants of other methods which habe absolute and ULPs (units of least precision)
tolerances as additional arguments. For example, approx_contains_point
is the tolerance
variant of contains_point
and checks if a given point is approximately in the bounding box.