pub struct BBox<S: Integer, V: Vector<S>> { /* fields omitted */ }
Expand description
A bounding box.
An axis-aligned non-empty volume of the same dimension as the space.
Constructs a bounding box from origin and size.
All coordinates of size must be positive to make the box non-empty.
Constructs a bounding box which contains a single point.
let p = p2d(2, 3);
assert_eq!(bb2d(2..3, 3..4), BBox2d::from_point(p));
👎 Deprecated:
Use from_corners instead.
Constructs the smallest bounding box containing two points.
Constructs the smallest bounding box containing two points.
let p0 = p2d(2, 3);
let p1 = p2d(-1, 4);
assert_eq!(bb2d(-1..3, 3..5), BBox2d::from_corners(p0, p1));
Constructs the minimal bounding box containing points from an iterator,
or None if the iterator is empty.
let points = vec![p2d(2, 3), p2d(-1, 4), p2d(1, 0)];
assert_eq!(Some(bb2d(-1..=2, 0..=4)), BBox2d::enclosing(&points));
The minimal point in the bounding box.
let b = bb2d(-1..3, 3..5);
assert_eq!(p2d(-1, 3), b.min());
The maximal point in the bounding box.
let b = bb2d(-1..3, 3..5);
assert_eq!(p2d(2, 4), b.max());
Returns a vector of the lengths for the coordinates.
let b = bb2d(-1..3, 3..5);
assert_eq!(p2d(2, 4), b.max());
Returns the volume of the bounding box.
let b = bb2d(-1..3, 3..5);
assert_eq!(8, b.volume());
The center point in the bounding box.
This is only the true center of the bounding box
if the bounding box has odd dimensions.
Otherwise the coordinates of the center are rounded
according to the rules for integer division, i.e. towards zero.
let b = bb2d(-1..4, 3..6);
assert_eq!(p2d(1, 4), b.center());
The least upper bound of two bounding boxes w.r.t. inclusion.
That is, the smallest bounding box encompassing the points in the two boxes.
let bb0 = bb2d(-2..3, -1..2);
let bb1 = bb2d(-5..4, 2..5);
assert_eq!(bb2d(-5..4, -1..5), bb0.lub(&bb1));
The intersection of two bounding boxes, or None if they don’t intersect.
let bb0 = bb2d(-2..=3, -1..=2);
let bb1 = bb2d(-5..=4, 0..=5);
assert_eq!(Some(bb2d(-2..=3, 0..=2)), bb0.intersection(&bb1));
Returns the smallest bounding box encompassing this box and a given point.
let bb = bb2d(-2..3, -1..2);
let p = p2d(3, 4);
assert_eq!(bb2d(-2..4, -1..5), bb.extend_to(p));
Returns the closest point inside the bounding box for a given point.
If the point is inside the bounding box it is returned unchanged.
Otherwise the coordinates that fall outside the ranges of the box
are clamped to the closest endpoints of the ranges.
let b = bb2d(-1..4, 3..6);
assert_eq!(p2d(3, 4), b.clamp(p2d(10, 4)));
Returns true if the point is inside the bounding box.
let b = bb2d(-1..4, 3..6);
assert!(b.contains(&p2d(0, 4)));
assert!(!b.contains(&p2d(10, 4)));
👎 Deprecated:
Use bb2d instead.
Constructs a bounding box from bounds.
As always, lower bbox are inclusive, upper bbox exclusive.
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (exclusive).
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (inclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (exclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (inclusive).
Returns the width of the bounding box.
Returns the height of the bounding box.
Returns the area of the bounding box.
The range of the x coordinate
The range of the y coordinate
Returns an iterator over the points in the bounding box.
Points are returned by row.
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (exclusive).
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (inclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (exclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (inclusive).
Returns the lower bound in the z-coordinate (inclusive).
Returns the upper bound in the z-coordinate (exclusive).
Returns the lower bound in the z-coordinate (inclusive).
Returns the upper bound in the z-coordinate (inclusive).
Returns the size of the x-dimension of the bounding box.
Returns the size of the y-dimension of the bounding box.
Returns the size of the z-dimension of the bounding box.
Returns the range of the x coordinate.
Returns the range of the y coordinate.
Returns the range of the z coordinate.
Returns an iterator over the points in the bounding box.
Points are returned by row.
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (exclusive).
Returns the lower bound in the x-coordinate (inclusive).
Returns the upper bound in the x-coordinate (inclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (exclusive).
Returns the lower bound in the y-coordinate (inclusive).
Returns the upper bound in the y-coordinate (inclusive).
Returns the lower bound in the z-coordinate (inclusive).
Returns the upper bound in the z-coordinate (exclusive).
Returns the lower bound in the z-coordinate (inclusive).
Returns the upper bound in the z-coordinate (inclusive).
Returns the lower bound in the w-coordinate (inclusive).
Returns the upper bound in the w-coordinate (exclusive).
Returns the lower bound in the w-coordinate (inclusive).
Returns the upper bound in the w-coordinate (inclusive).
Returns the size of the x-dimension of the bounding box.
Returns the size of the y-dimension of the bounding box.
Returns the size of the z-dimension of the bounding box.
Returns the size of the w-dimension of the bounding box.
Returns the range of the x coordinate.
Returns the range of the y coordinate.
Returns the range of the z coordinate.
Returns the range of the w coordinate.
Returns an iterator over the points in the bounding box.
Points are returned by row.
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.