pub struct BoundingBox<V>(_, _);
Expand description

bounding box

Implementations§

Creates an empty bounding box

Adds a point to the bounding box.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  1.0));
bdd_box.push(&Vector2::new(1.0,  -1.0));
assert_eq!(bdd_box.min(), &Vector2::new(-1.0,  -1.0));
assert_eq!(bdd_box.max(), &Vector2::new(1.0,  1.0));
Remarks

If the added point has NAN component, then the point is not added.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  1.0));
bdd_box.push(&Vector2::new(1.0,  -1.0));
bdd_box.push(&Vector2::new(std::f64::NAN, 1.0));
bdd_box.push(&Vector2::new(-1.0, std::f64::NAN));
assert_eq!(bdd_box.min(), &Vector2::new(-1.0,  -1.0));
assert_eq!(bdd_box.max(), &Vector2::new(1.0,  1.0));

Returns the bounding box is empty or not.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
assert!(bdd_box.is_empty());
bdd_box.push(&Vector2::new(-1.0,  1.0));
assert!(!bdd_box.is_empty());

Returns the reference to the maximum point.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  1.0));
bdd_box.push(&Vector2::new(1.0,  -1.0));
assert_eq!(bdd_box.max(), &Vector2::new(1.0,  1.0));
Remarks

If the bounding box is empty, returned vector consists NEG_INFINITY components.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector2>::new();
assert_eq!(bdd_box.max(), &Vector2::from([f64::NEG_INFINITY; 2]));

Returns the reference to the minimal point.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  1.0));
bdd_box.push(&Vector2::new(1.0,  -1.0));
assert_eq!(bdd_box.min(), &Vector2::new(-1.0,  -1.0));
Remarks

If the bounding box is empty, returned vector consists INFINITY components.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector2>::new();
assert_eq!(bdd_box.min(), &Vector2::from([f64::INFINITY; 2]));

Returns the diagonal vector.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-2.0,  -3.0));
bdd_box.push(&Vector2::new(6.0,  4.0));
assert_eq!(bdd_box.diagonal(), Vector2::new(8.0,  7.0));
Remarks

If the bounding box is empty, returned vector consists f64::NEG_INFINITY components.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector2>::new();
assert_eq!(bdd_box.diagonal(), Vector2::new(f64::NEG_INFINITY, f64::NEG_INFINITY));

Returns the diameter of the bounding box.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  -3.0));
bdd_box.push(&Vector2::new(2.0,  1.0));
assert_eq!(bdd_box.diameter(), 5.0);
Remarks

If the bounding box is empty, returns f64::NEG_INFINITY.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector3>::new();
assert_eq!(bdd_box.diameter(), f64::NEG_INFINITY);

Returns the maximum length of the edges of the bounding box.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector3::new(-1.0, -3.0,  2.0));
bdd_box.push(&Vector3::new(2.0, 1.0,  10.0));
assert_eq!(bdd_box.size(), 8.0);
Remarks

If the bounding box is empty, returns f64::NEG_INFINITY.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector3>::new();
assert_eq!(bdd_box.size(), f64::NEG_INFINITY);

Returns the center of the bounding box.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::new();
bdd_box.push(&Vector2::new(-1.0,  -3.0));
bdd_box.push(&Vector2::new(5.0,  1.0));
assert_eq!(bdd_box.center(), Vector2::new(2.0,  -1.0));
Remarks

If the bounding box is empty, returned vector consists std::f64::NAN components.

use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box = BoundingBox::<Vector3>::new();
let center = bdd_box.center();
assert!(center[0].is_nan());
assert!(center[1].is_nan());
assert!(center[2].is_nan());

Trait Implementations§

Returns the direct sum of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0, 6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0, 4.0),
]);
let bdd_box = &bdd_box0 + &bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(3.0, 1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0, 6.0));

let cloned_bdd_box = &bdd_box + &BoundingBox::new();
assert_eq!(cloned_bdd_box.min(), &Vector2::new(3.0, 1.0));
assert_eq!(cloned_bdd_box.max(), &Vector2::new(7.0, 6.0));
The resulting type after applying the + operator.

Returns the direct sum of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = bdd_box0 + &bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

let cloned_bdd_box = bdd_box + &BoundingBox::new();
assert_eq!(cloned_bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(cloned_bdd_box.max(), &Vector2::new(7.0,  6.0));
The resulting type after applying the + operator.

Returns the direct sum of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = &bdd_box0 + bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

let cloned_bdd_box = &bdd_box + BoundingBox::new();
assert_eq!(cloned_bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(cloned_bdd_box.max(), &Vector2::new(7.0,  6.0));
The resulting type after applying the + operator.

Returns the direct sum of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = bdd_box0 + bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

let cloned_bdd_box = bdd_box + BoundingBox::new();
assert_eq!(cloned_bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(cloned_bdd_box.max(), &Vector2::new(7.0,  6.0));
The resulting type after applying the + operator.

Puts the points in other into self.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
bdd_box += &BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

bdd_box += &BoundingBox::new();
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

Puts the points in other into self.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
bdd_box += BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

bdd_box += BoundingBox::new();
assert_eq!(bdd_box.min(), &Vector2::new(3.0,  1.0));
assert_eq!(bdd_box.max(), &Vector2::new(7.0,  6.0));

Returns the intersection of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = &bdd_box0 ^ &bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

let new_empty = &bdd_box ^ &BoundingBox::new();
assert!(new_empty.is_empty());
The resulting type after applying the ^ operator.

Returns the intersection of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0,  2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0,  1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = bdd_box0 ^ &bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

let new_empty = bdd_box ^ &BoundingBox::new();
assert!(new_empty.is_empty());
The resulting type after applying the ^ operator.

Returns the intersection of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0,  2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0,  1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = &bdd_box0 ^ bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

let new_empty = &bdd_box ^ BoundingBox::new();
assert!(new_empty.is_empty());
The resulting type after applying the ^ operator.

Returns the intersection of self and other.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let bdd_box0 = BoundingBox::from_iter(&[
    Vector2::new(3.0,  2.0), Vector2::new(5.0,  6.0),
]);
let bdd_box1 = BoundingBox::from_iter(&[
    Vector2::new(4.0,  1.0), Vector2::new(7.0,  4.0),
]);
let bdd_box = bdd_box0 ^ bdd_box1;
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

let new_empty = bdd_box ^ BoundingBox::new();
assert!(new_empty.is_empty());
The resulting type after applying the ^ operator.

Assigns the intersection of self and other to self.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
bdd_box ^= &BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

bdd_box ^= &BoundingBox::new();
assert!(bdd_box.is_empty());

Assigns the intersection of self and other to self.

Examples
use truck_base::{cgmath64::*, bounding_box::*, tolerance::*};
let mut bdd_box = BoundingBox::from_iter(&[
    Vector2::new(3.0, 2.0), Vector2::new(5.0,  6.0),
]);
bdd_box ^= BoundingBox::from_iter(&[
    Vector2::new(4.0, 1.0), Vector2::new(7.0,  4.0),
]);
assert_eq!(bdd_box.min(), &Vector2::new(4.0,  2.0));
assert_eq!(bdd_box.max(), &Vector2::new(5.0,  4.0));

bdd_box ^= BoundingBox::new();
assert!(bdd_box.is_empty());
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Inclusion relationship

Examples
use truck_base::{cgmath64::*, bounding_box::*};
let bbx0 = BoundingBox::from_iter(&[
    Point2::new(0.0, 0.0),
    Point2::new(1.0, 1.0),
]);
let bbx1 = BoundingBox::from_iter(&[
    Point2::new(0.25, 0.25),
    Point2::new(0.75, 0.75),
]);
// bbx0 includes bbx1.
assert!(bbx0 > bbx1);

let bbx2 = BoundingBox::from_iter(&[
    Point2::new(-1.0, -1.0),
    Point2::new(0.75, 0.75),
]);
// bbx0 does not include bbx2, and bbx2 does not include bbx0.
assert!(!(bbx0 > bbx2));
assert!(!(bbx0 < bbx2));
assert!(!(bbx0 == bbx2));
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.