Skip to main content

Cuboid

Type Alias Cuboid 

Source
pub type Cuboid = Hypercuboid<3>;
Expand description

An axis-aligned cuboid.

§Examples

Basic construction and methods:

use hoomd_geometry::{Volume, shape::Cuboid};

let cuboid = Cuboid {
    edge_lengths: [2.0.try_into()?, 4.0.try_into()?, 7.0.try_into()?],
};
assert_eq!(cuboid.volume(), 56.0);

Intersection tests:

use hoomd_geometry::{Convex, IntersectsAt, shape::Cuboid};
use hoomd_vector::{Cartesian, Versor};

let cuboid = Cuboid {
    edge_lengths: [4.0.try_into()?, 2.0.try_into()?, 7.0.try_into()?],
};
let cuboid = Convex(cuboid);

assert!(!cuboid.intersects_at(
    &cuboid,
    &[0.0, 2.1, 0.0].into(),
    &Versor::default()
));
assert!(cuboid.intersects_at(
    &cuboid,
    &[2.0, 1.0, 6.5].into(),
    &Versor::default()
));

Aliased Type§

pub struct Cuboid {
    pub edge_lengths: [PositiveReal; 3],
}

Fields§

§edge_lengths: [PositiveReal; 3]

The lengths of each edge of the cuboid.