bbox 0.7.1

Managing axis aligned 3d Bounding Boxes.
Documentation

stl_io

Build Status Cargo License: GPL-3.0 Downloads

bbox is crate for managing axis aligned 3d Bounding Boxes. Bounding Boxes can be created, dilated, transformed and joined with other Bounding Boxes using CSG operations. Finally you can test whether or not a Bounding Box contains some point and what approximate distance a Point has to the Box.

Examples

Intersect two Bounding Boxes

extern crate nalgebra as na;
extern crate bbox;
let bbox1 = bbox::BoundingBox::<f64>::new(na::Point3::new(0., 0., 0.),
                                          na::Point3::new(1., 2., 3.));
let bbox2 = bbox::BoundingBox::<f64>::new(na::Point3::new(-1., -2., -3.),
                                          na::Point3::new(3., 2., 1.));
let intersection = bbox1.intersection(&bbox2);

Rotate a Bounding Box:

extern crate nalgebra as na;
extern crate bbox;
let rotation = na::Rotation::from_euler_angles(10., 11., 12.).to_homogeneous();
let bbox = bbox::BoundingBox::<f64>::new(na::Point3::new(0., 0., 0.),
                                         na::Point3::new(1., 2., 3.));
let rotated_box = bbox.transform(&rotation);