Struct parry3d::bounding_volume::Aabb
source · #[repr(C)]pub struct Aabb {
pub mins: Point<Real>,
pub maxs: Point<Real>,
}
Expand description
An Axis Aligned Bounding Box.
Fields§
§mins: Point<Real>
§maxs: Point<Real>
Implementations§
source§impl Aabb
impl Aabb
sourcepub const EDGES_VERTEX_IDS: [(usize, usize); 12] = _
pub const EDGES_VERTEX_IDS: [(usize, usize); 12] = _
The vertex indices of each edge of this Aabb
.
This gives, for each edge of this Aabb
, the indices of its
vertices when taken from the self.vertices()
array.
Here is how the faces are numbered, assuming
a right-handed coordinate system:
y 3 - 2
| 7 − 6 |
___ x | | 1 (the zero is below 3 and on the left of 1,
/ 4 - 5 hidden by the 4-5-6-7 face.)
z
sourcepub const FACES_VERTEX_IDS: [(usize, usize, usize, usize); 6] = _
pub const FACES_VERTEX_IDS: [(usize, usize, usize, usize); 6] = _
The vertex indices of each face of this Aabb
.
This gives, for each face of this Aabb
, the indices of its
vertices when taken from the self.vertices()
array.
Here is how the faces are numbered, assuming
a right-handed coordinate system:
y 3 - 2
| 7 − 6 |
___ x | | 1 (the zero is below 3 and on the left of 1,
/ 4 - 5 hidden by the 4-5-6-7 face.)
z
sourcepub fn new(mins: Point<Real>, maxs: Point<Real>) -> Aabb
pub fn new(mins: Point<Real>, maxs: Point<Real>) -> Aabb
Creates a new Aabb.
§Arguments:
mins
- position of the point with the smallest coordinates.maxs
- position of the point with the highest coordinates. Each component ofmins
must be smaller than the related components ofmaxs
.
sourcepub fn new_invalid() -> Self
pub fn new_invalid() -> Self
Creates an invalid Aabb
with mins
components set to Real::max_values
and maxs
components set to -Real::max_values
.
This is often used as the initial values of some Aabb
merging algorithms.
sourcepub fn from_half_extents(
center: Point<Real>,
half_extents: Vector<Real>
) -> Self
pub fn from_half_extents( center: Point<Real>, half_extents: Vector<Real> ) -> Self
Creates a new Aabb
from its center and its half-extents.
sourcepub fn from_points<'a, I>(pts: I) -> Self
pub fn from_points<'a, I>(pts: I) -> Self
Creates a new Aabb
from a set of points.
sourcepub fn half_extents(&self) -> Vector<Real>
pub fn half_extents(&self) -> Vector<Real>
The half extents of this Aabb
.
sourcepub fn take_point(&mut self, pt: Point<Real>)
pub fn take_point(&mut self, pt: Point<Real>)
Enlarges this Aabb
so it also contains the point pt
.
sourcepub fn transform_by(&self, m: &Isometry<Real>) -> Self
pub fn transform_by(&self, m: &Isometry<Real>) -> Self
Computes the Aabb
bounding self
transformed by m
.
pub fn scaled(self, scale: &Vector<Real>) -> Self
sourcepub fn scaled_wrt_center(self, scale: &Vector<Real>) -> Self
pub fn scaled_wrt_center(self, scale: &Vector<Real>) -> Self
Returns an AABB with the same center as self
but with extents scaled by scale
.
§Parameters
scale
: the scaling factor. It can be non-uniform and/or negative. The AABB being symmetric wrt. its center, a negative scale value has the same effect as scaling by its absolute value.
sourcepub fn bounding_sphere(&self) -> BoundingSphere
pub fn bounding_sphere(&self) -> BoundingSphere
The smallest bounding sphere containing this Aabb
.
sourcepub fn contains_local_point(&self, point: &Point<Real>) -> bool
pub fn contains_local_point(&self, point: &Point<Real>) -> bool
Does this AABB contains a point expressed in the same coordinate frame as self
?
sourcepub fn intersects_moving_aabb(&self, aabb2: &Self, vel12: Vector<Real>) -> bool
pub fn intersects_moving_aabb(&self, aabb2: &Self, vel12: Vector<Real>) -> bool
Does this AABB intersects an AABB aabb2
moving at velocity vel12
relative to self
?
sourcepub fn intersection(&self, other: &Aabb) -> Option<Aabb>
pub fn intersection(&self, other: &Aabb) -> Option<Aabb>
Computes the intersection of this Aabb
and another one.
sourcepub fn difference(&self, rhs: &Aabb) -> ArrayVec<Self, TWO_DIM>
pub fn difference(&self, rhs: &Aabb) -> ArrayVec<Self, TWO_DIM>
Returns the difference between this Aabb
and rhs
.
Removing another Aabb
from self
will result in zero, one, or up to 4 (in 2D) or 8 (in 3D)
new smaller Aabbs.
sourcepub fn difference_with_cut_sequence(
&self,
rhs: &Aabb
) -> (ArrayVec<Self, TWO_DIM>, ArrayVec<(i8, Real), TWO_DIM>)
pub fn difference_with_cut_sequence( &self, rhs: &Aabb ) -> (ArrayVec<Self, TWO_DIM>, ArrayVec<(i8, Real), TWO_DIM>)
Returns the difference between this Aabb
and rhs
.
Removing another Aabb
from self
will result in zero, one, or up to 4 (in 2D) or 8 (in 3D)
new smaller Aabbs.
§Return
This returns a pair where the first item are the new Aabbs and the the second item is
the sequance of cuts applied to self
to obtain the new Aabbs. Each cut is performed
along one axis identified by -1, -2, -3
for -X, -Y, -Z
and 1, 2, 3
for +X, +Y, +Z
, and
the plane’s bias.
The cuts are applied sequancially. For example, if result.1[0]
contains 1
, then it means
that result.0[0]
is equal to the piece of self
lying in the negative half-space delimited
by the plane with outward normal +X
. Then, the other piece of self
generated by this cut
(i.e. the piece of self
lying in the positive half-space delimited by the plane with outward
normal +X
) is the one that will be affected by the next cut.
The returned cut sequence will be empty if the aabbs are disjoint.
sourcepub fn split_at_center(&self) -> [Aabb; 8]
pub fn split_at_center(&self) -> [Aabb; 8]
Splits this Aabb
at its center, into eight parts (as in an octree).
sourcepub fn project_on_axis(&self, axis: &UnitVector<Real>) -> (Real, Real)
pub fn project_on_axis(&self, axis: &UnitVector<Real>) -> (Real, Real)
Projects every point of Aabb
on an arbitrary axis.
pub fn intersects_spiral( &self, point: &Point<Real>, center: &Point<Real>, axis: &UnitVector<Real>, linvel: &Vector<Real>, angvel: Real ) -> bool
source§impl Aabb
impl Aabb
sourcepub fn clip_segment(
&self,
pa: &Point<Real>,
pb: &Point<Real>
) -> Option<Segment>
pub fn clip_segment( &self, pa: &Point<Real>, pb: &Point<Real> ) -> Option<Segment>
Computes the intersection of a segment with this Aabb.
Returns None
if there is no intersection.
sourcepub fn clip_line_parameters(
&self,
orig: &Point<Real>,
dir: &Vector<Real>
) -> Option<(Real, Real)>
pub fn clip_line_parameters( &self, orig: &Point<Real>, dir: &Vector<Real> ) -> Option<(Real, Real)>
Computes the parameters of the two intersection points between a line and this Aabb.
The parameters are such that the point are given by orig + dir * parameter
.
Returns None
if there is no intersection.
sourcepub fn clip_line(
&self,
orig: &Point<Real>,
dir: &Vector<Real>
) -> Option<Segment>
pub fn clip_line( &self, orig: &Point<Real>, dir: &Vector<Real> ) -> Option<Segment>
Computes the intersection segment between a line and this Aabb.
Returns None
if there is no intersection.
source§impl Aabb
impl Aabb
sourcepub fn clip_polygon(&self, points: &mut Vec<Point<Real>>)
pub fn clip_polygon(&self, points: &mut Vec<Point<Real>>)
Computes the intersections between this Aabb and the given polygon.
The results is written into points
directly. The input points are
assumed to form a convex polygon where all points lie on the same plane.
In order to avoid internal allocations, uses self.clip_polygon_with_workspace
instead.
sourcepub fn clip_polygon_with_workspace(
&self,
points: &mut Vec<Point<Real>>,
workspace: &mut Vec<Point<Real>>
)
pub fn clip_polygon_with_workspace( &self, points: &mut Vec<Point<Real>>, workspace: &mut Vec<Point<Real>> )
Computes the intersections between this Aabb and the given polygon.
The results is written into points
directly. The input points are
assumed to form a convex polygon where all points lie on the same plane.
source§impl Aabb
impl Aabb
sourcepub fn canonical_split(
&self,
axis: usize,
bias: Real,
epsilon: Real
) -> SplitResult<Self>
pub fn canonical_split( &self, axis: usize, bias: Real, epsilon: Real ) -> SplitResult<Self>
Splits this Aabb
along the given canonical axis.
This will split the Aabb
by a plane with a normal with it’s axis
-th component set to 1.
The splitting plane is shifted wrt. the origin by the bias
(i.e. it passes through the point
equal to normal * bias
).
§Result
Returns the result of the split. The first Aabb
returned is the piece lying on the negative
half-space delimited by the splitting plane. The second Aabb
returned is the piece lying on the
positive half-space delimited by the splitting plane.
Trait Implementations§
source§impl BoundingVolume for Aabb
impl BoundingVolume for Aabb
source§fn center(&self) -> Point<Real>
fn center(&self) -> Point<Real>
source§fn intersects(&self, other: &Aabb) -> bool
fn intersects(&self, other: &Aabb) -> bool
source§fn merge(&mut self, other: &Aabb)
fn merge(&mut self, other: &Aabb)
source§impl PartialEq for Aabb
impl PartialEq for Aabb
source§impl PointQuery for Aabb
impl PointQuery for Aabb
source§fn project_local_point(&self, pt: &Point<Real>, solid: bool) -> PointProjection
fn project_local_point(&self, pt: &Point<Real>, solid: bool) -> PointProjection
self
. Read moresource§fn project_local_point_and_get_feature(
&self,
pt: &Point<Real>
) -> (PointProjection, FeatureId)
fn project_local_point_and_get_feature( &self, pt: &Point<Real> ) -> (PointProjection, FeatureId)
self
and returns the id of the
feature the point was projected on.source§fn distance_to_local_point(&self, pt: &Point<Real>, solid: bool) -> Real
fn distance_to_local_point(&self, pt: &Point<Real>, solid: bool) -> Real
self
.source§fn project_local_point_with_max_dist(
&self,
pt: &Point<Real>,
solid: bool,
max_dist: Real
) -> Option<PointProjection>
fn project_local_point_with_max_dist( &self, pt: &Point<Real>, solid: bool, max_dist: Real ) -> Option<PointProjection>
self
, unless the projection lies further than the given max distance. Read moresource§fn project_point_with_max_dist(
&self,
m: &Isometry<Real>,
pt: &Point<Real>,
solid: bool,
max_dist: Real
) -> Option<PointProjection>
fn project_point_with_max_dist( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool, max_dist: Real ) -> Option<PointProjection>
self
transformed by m
, unless the projection lies further than the given max distance.source§fn contains_local_point(&self, pt: &Point<Real>) -> bool
fn contains_local_point(&self, pt: &Point<Real>) -> bool
self
.source§fn project_point(
&self,
m: &Isometry<Real>,
pt: &Point<Real>,
solid: bool
) -> PointProjection
fn project_point( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool ) -> PointProjection
self
transformed by m
.source§fn distance_to_point(
&self,
m: &Isometry<Real>,
pt: &Point<Real>,
solid: bool
) -> Real
fn distance_to_point( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool ) -> Real
self
transformed by m
.source§fn project_point_and_get_feature(
&self,
m: &Isometry<Real>,
pt: &Point<Real>
) -> (PointProjection, FeatureId)
fn project_point_and_get_feature( &self, m: &Isometry<Real>, pt: &Point<Real> ) -> (PointProjection, FeatureId)
self
transformed by m
and returns the id of the
feature the point was projected on.source§impl RayCast for Aabb
impl RayCast for Aabb
source§fn cast_local_ray(
&self,
ray: &Ray,
max_time_of_impact: Real,
solid: bool
) -> Option<Real>
fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<Real>
source§fn cast_local_ray_and_get_normal(
&self,
ray: &Ray,
max_time_of_impact: Real,
solid: bool
) -> Option<RayIntersection>
fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<RayIntersection>
source§fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: Real) -> bool
fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: Real) -> bool
source§fn cast_ray(
&self,
m: &Isometry<Real>,
ray: &Ray,
max_time_of_impact: Real,
solid: bool
) -> Option<Real>
fn cast_ray( &self, m: &Isometry<Real>, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<Real>
source§fn cast_ray_and_get_normal(
&self,
m: &Isometry<Real>,
ray: &Ray,
max_time_of_impact: Real,
solid: bool
) -> Option<RayIntersection>
fn cast_ray_and_get_normal( &self, m: &Isometry<Real>, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<RayIntersection>
impl Copy for Aabb
impl StructuralPartialEq for Aabb
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin for Aabb
impl UnwindSafe for Aabb
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 moresource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.