Crates.io | bbox |
lib.rs | bbox |
version | 0.14.1 |
source | src |
created_at | 2018-04-11 21:21:12.024741 |
updated_at | 2024-08-10 15:57:25.850606 |
description | Managing axis aligned 3d Bounding Boxes. |
homepage | |
repository | https://github.com/hmeyer/bbox |
max_upload_size | |
id | 60205 |
size | 18,743 |
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.
Intersect two Bounding Boxes
use nalgebra as na;
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:
use nalgebra as na;
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);
Is a point contained in the Box?
use nalgebra as na;
let bbox = bbox::BoundingBox::<f64>::new(na::Point3::new(0., 0., 0.),
na::Point3::new(1., 2., 3.));
let result = bbox.contains(na::Point3::new(1., 1., 1.));
Calculate approximate distance of a point to the Box:
use nalgebra as na;
let bbox = bbox::BoundingBox::<f64>::new(na::Point3::new(0., 0., 0.),
na::Point3::new(1., 2., 3.));
let distance = bbox.distance(na::Point3::new(1., 1., 1.));
mint
- Enable interoperation with other math libraries through the
mint
interface.