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

source

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
source

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
source

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 of mins must be smaller than the related components of maxs.
source

pub fn new_invalid() -> Self

Creates an invalid Aabb with mins components set to Real::max_values and maxscomponents set to -Real::max_values.

This is often used as the initial values of some Aabb merging algorithms.

source

pub fn from_half_extents( center: Point<Real>, half_extents: Vector<Real> ) -> Self

Creates a new Aabb from its center and its half-extents.

source

pub fn from_points<'a, I>(pts: I) -> Self
where I: IntoIterator<Item = &'a Point<Real>>,

Creates a new Aabb from a set of points.

source

pub fn center(&self) -> Point<Real>

The center of this Aabb.

source

pub fn half_extents(&self) -> Vector<Real>

The half extents of this Aabb.

source

pub fn volume(&self) -> Real

The volume of this Aabb.

source

pub fn extents(&self) -> Vector<Real>

The extents of this Aabb.

source

pub fn take_point(&mut self, pt: Point<Real>)

Enlarges this Aabb so it also contains the point pt.

source

pub fn transform_by(&self, m: &Isometry<Real>) -> Self

Computes the Aabb bounding self transformed by m.

source

pub fn scaled(self, scale: &Vector<Real>) -> Self

source

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.
source

pub fn bounding_sphere(&self) -> BoundingSphere

The smallest bounding sphere containing this Aabb.

source

pub fn contains_local_point(&self, point: &Point<Real>) -> bool

Does this AABB contains a point expressed in the same coordinate frame as self?

source

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?

source

pub fn intersection(&self, other: &Aabb) -> Option<Aabb>

Computes the intersection of this Aabb and another one.

source

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.

source

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.

source

pub fn vertices(&self) -> [Point<Real>; 8]

Computes the vertices of this Aabb.

source

pub fn split_at_center(&self) -> [Aabb; 8]

Splits this Aabb at its center, into eight parts (as in an octree).

source

pub fn project_on_axis(&self, axis: &UnitVector<Real>) -> (Real, Real)

Projects every point of Aabb on an arbitrary axis.

source

pub fn intersects_spiral( &self, point: &Point<Real>, center: &Point<Real>, axis: &UnitVector<Real>, linvel: &Vector<Real>, angvel: Real ) -> bool

source§

impl Aabb

source

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.

source

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.

source

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

pub fn clip_ray_parameters(&self, ray: &Ray) -> Option<(Real, Real)>

Computes the parameters of the two intersection points between a ray and this Aabb.

The parameters are such that the point are given by ray.orig + ray.dir * parameter. Returns None if there is no intersection.

source

pub fn clip_ray(&self, ray: &Ray) -> Option<Segment>

Computes the intersection segment between a ray and this Aabb.

Returns None if there is no intersection.

source§

impl Aabb

source

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.

source

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

source

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.

source§

impl Aabb

source

pub fn to_outline(&self) -> (Vec<Point<Real>>, Vec<[u32; 2]>)

Outlines this Aabb’s shape using polylines.

source§

impl Aabb

source

pub fn to_trimesh(&self) -> (Vec<Point3<Real>>, Vec<[u32; 3]>)

Discretize the boundary of this Aabb as a triangle-mesh.

Trait Implementations§

source§

impl BoundingVolume for Aabb

source§

fn center(&self) -> Point<Real>

Returns a point inside of this bounding volume. This is ideally its center.
source§

fn intersects(&self, other: &Aabb) -> bool

Checks if this bounding volume intersect with another one.
source§

fn contains(&self, other: &Aabb) -> bool

Checks if this bounding volume contains another one.
source§

fn merge(&mut self, other: &Aabb)

Merges this bounding volume with another one. The merge is done in-place.
source§

fn merged(&self, other: &Aabb) -> Aabb

Merges this bounding volume with another one.
source§

fn loosen(&mut self, amount: Real)

Enlarges this bounding volume.
source§

fn loosened(&self, amount: Real) -> Aabb

Creates a new, enlarged version, of this bounding volume.
source§

fn tighten(&mut self, amount: Real)

Tighten this bounding volume.
source§

fn tightened(&self, amount: Real) -> Aabb

Creates a new, tightened version, of this bounding volume.
source§

impl Clone for Aabb

source§

fn clone(&self) -> Aabb

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Aabb

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Aabb

source§

fn eq(&self, other: &Aabb) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PointQuery for Aabb

source§

fn project_local_point(&self, pt: &Point<Real>, solid: bool) -> PointProjection

Projects a point on self. Read more
source§

fn project_local_point_and_get_feature( &self, pt: &Point<Real> ) -> (PointProjection, FeatureId)

Projects a point on the boundary of 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

Computes the minimal distance between a point and self.
source§

fn project_local_point_with_max_dist( &self, pt: &Point<Real>, solid: bool, max_dist: Real ) -> Option<PointProjection>

Projects a point on self, unless the projection lies further than the given max distance. Read more
source§

fn project_point_with_max_dist( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool, max_dist: Real ) -> Option<PointProjection>

Projects a point on self transformed by m, unless the projection lies further than the given max distance.
source§

fn contains_local_point(&self, pt: &Point<Real>) -> bool

Tests if the given point is inside of self.
source§

fn project_point( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool ) -> PointProjection

Projects a point on self transformed by m.
source§

fn distance_to_point( &self, m: &Isometry<Real>, pt: &Point<Real>, solid: bool ) -> Real

Computes the minimal distance between a point and self transformed by m.
source§

fn project_point_and_get_feature( &self, m: &Isometry<Real>, pt: &Point<Real> ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self transformed by m and returns the id of the feature the point was projected on.
source§

fn contains_point(&self, m: &Isometry<Real>, pt: &Point<Real>) -> bool

Tests if the given point is inside of self transformed by m.
source§

impl RayCast for Aabb

source§

fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<Real>

Computes the time of impact between this transform shape and a ray.
source§

fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
source§

fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: Real) -> bool

Tests whether a ray intersects this transformed shape.
source§

fn cast_ray( &self, m: &Isometry<Real>, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<Real>

Computes the time of impact between this transform shape and a ray.
source§

fn cast_ray_and_get_normal( &self, m: &Isometry<Real>, ray: &Ray, max_time_of_impact: Real, solid: bool ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
source§

fn intersects_ray( &self, m: &Isometry<Real>, ray: &Ray, max_time_of_impact: Real ) -> bool

Tests whether a ray intersects this transformed shape.
source§

impl Copy for Aabb

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,