pub struct Obb3<S> {
pub center: Point3<S>,
pub half_extent_x: Positive<S>,
pub half_extent_y: Positive<S>,
pub half_extent_z: Positive<S>,
pub orientation: Angles3<S>,
}Expand description
3D oriented bounding box
Fields§
§center: Point3<S>§half_extent_x: Positive<S>§half_extent_y: Positive<S>§half_extent_z: Positive<S>§orientation: Angles3<S>Implementations§
Source§impl<S: Ring> Obb3<S>
impl<S: Ring> Obb3<S>
Sourcepub const fn new(
center: Point3<S>,
half_extent_x: Positive<S>,
half_extent_y: Positive<S>,
half_extent_z: Positive<S>,
orientation: Angles3<S>,
) -> Self
pub const fn new( center: Point3<S>, half_extent_x: Positive<S>, half_extent_y: Positive<S>, half_extent_z: Positive<S>, orientation: Angles3<S>, ) -> Self
Construct a new OBB
Sourcepub fn containing_points_with_orientation(
points: &[Point3<S>],
orientation: Angles3<S>,
) -> Self
pub fn containing_points_with_orientation( points: &[Point3<S>], orientation: Angles3<S>, ) -> Self
Compute the OBB of a given orientation
Sourcepub fn containing_points_approx(points: &[Point3<S>]) -> Option<Self>
pub fn containing_points_approx(points: &[Point3<S>]) -> Option<Self>
Construct an approximate minimum OBB containing the convex hull of a given set of points.
Returns None if fewer than 4 points are given or if points span an empty set:
assert!(Obb3::containing_points_approx (
&[[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]].map (Point3::from)
).is_none());
assert!(Obb3::containing_points_approx (
&[[1.0, 0.0, 1.0], [0.0, 1.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, -1.0]]
.map (Point3::from)
).is_none());Sourcepub fn containing_approx(
hull: &Hull3<S>,
mesh: &VertexEdgeTriangleMesh,
) -> Option<Self>
pub fn containing_approx( hull: &Hull3<S>, mesh: &VertexEdgeTriangleMesh, ) -> Option<Self>
Construct an approximate minimum OBB containing the given convex hull and corresponding mesh.
Returns None if fewer than 4 points are given or if points span an empty set:
let (hull, mesh) = Hull3::from_points_with_mesh (
&[[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]].map (Point3::from)
).unwrap();
assert!(Obb3::containing_approx (&hull, &mesh).is_none());
let (hull, mesh) = Hull3::from_points_with_mesh (
&[[1.0, 0.0, 1.0], [0.0, 1.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, -1.0]]
.map (Point3::from)
).unwrap();
assert!(Obb3::containing_approx (&hull, &mesh).is_none());Sourcepub fn containing_approx_pca(hull: &Hull3<S>) -> Option<Self>
pub fn containing_approx_pca(hull: &Hull3<S>) -> Option<Self>
Construct an approximate minimum OBB containing the given convex hull of points oriented according to principal component analysis bases.
Returns None if fewer than 4 points are given or if points span an empty set:
let hull = Hull3::from_points (
&[[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]].map (Point3::from)
).unwrap();
assert!(Obb3::containing_approx_pca (&hull).is_none());
let hull = Hull3::from_points (
&[[1.0, 0.0, 1.0], [0.0, 1.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, -1.0]]
.map (Point3::from)
).unwrap();
assert!(Obb3::containing_approx_pca (&hull).is_none());pub const fn center(&self) -> Point3<S>
pub const fn half_extent_x(&self) -> Positive<S>
pub const fn half_extent_y(&self) -> Positive<S>
pub const fn half_extent_z(&self) -> Positive<S>
pub const fn orientation(&self) -> Angles3<S>
pub fn dimensions(&self) -> Vector3<S>where
S: Field,
pub fn extents(&self) -> Vector3<S>where
S: Field,
Sourcepub fn width(&self) -> Positive<S>where
S: OrderedField,
pub fn width(&self) -> Positive<S>where
S: OrderedField,
X dimension
Sourcepub fn depth(&self) -> Positive<S>where
S: OrderedField,
pub fn depth(&self) -> Positive<S>where
S: OrderedField,
Y dimension
Sourcepub fn height(&self) -> Positive<S>where
S: OrderedField,
pub fn height(&self) -> Positive<S>where
S: OrderedField,
Z dimension
pub fn volume(&self) -> Positive<S>where
S: OrderedField,
pub fn corners(&self) -> [Point3<S>; 8]
Sourcepub fn contains(&self, point: &Point3<S>) -> bool
pub fn contains(&self, point: &Point3<S>) -> bool
Check if point is contained by the bounding box
Sourcepub fn dilate(self, amount: S) -> Selfwhere
S: OrderedField,
pub fn dilate(self, amount: S) -> Selfwhere
S: OrderedField,
Increase or decrease each dimension by the given amount.
Panics if any dimension would become zero or negative:
let x = Obb3::new (
Point3::origin(),
Positive::unchecked (0.5),
Positive::unchecked (0.5),
Positive::unchecked (0.5),
Angles3::zero()
);
let y = x.dilate (-1.0); // panic!Trait Implementations§
impl<S: Copy> Copy for Obb3<S>
impl<S: Eq> Eq for Obb3<S>
impl<S> StructuralPartialEq for Obb3<S>
Auto Trait Implementations§
impl<S> Freeze for Obb3<S>where
S: Freeze,
impl<S> RefUnwindSafe for Obb3<S>where
S: RefUnwindSafe,
impl<S> Send for Obb3<S>where
S: Send,
impl<S> Sync for Obb3<S>where
S: Sync,
impl<S> Unpin for Obb3<S>where
S: Unpin,
impl<S> UnwindSafe for Obb3<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more