pub struct HalfSpace<const D: usize> {
pub normal: SVector<f64, D>,
pub offset: f64,
}Expand description
D-dimensional half-space: the set of points where normal · p <= offset.
The boundary plane has equation normal · p = offset.
normal must be a unit vector.
Fields§
§normal: SVector<f64, D>Outward-pointing unit normal of the boundary plane.
offset: f64Signed distance from the origin to the boundary plane along the normal. Positive = plane is on the positive side of the origin.
Implementations§
Source§impl<const D: usize> HalfSpace<D>
impl<const D: usize> HalfSpace<D>
Sourcepub fn new(normal: SVector<f64, D>, offset: f64) -> Self
pub fn new(normal: SVector<f64, D>, offset: f64) -> Self
Create a half-space from a normal and offset. The normal should be a unit vector (not enforced, but expected).
Sourcepub fn ground(axis: usize, height: f64) -> Self
pub fn ground(axis: usize, height: f64) -> Self
Create a ground plane at the given height along the given axis. Normal points in the positive axis direction (upward for Y-up).
Sourcepub fn signed_distance(&self, point: &SVector<f64, D>) -> f64
pub fn signed_distance(&self, point: &SVector<f64, D>) -> f64
Signed distance from a point to the boundary plane. Positive = point is on the “outside” (normal side). Negative = point is inside the solid half-space.
Sourcepub fn project(&self, point: &SVector<f64, D>) -> SVector<f64, D>
pub fn project(&self, point: &SVector<f64, D>) -> SVector<f64, D>
Project a point onto the boundary plane.
Sourcepub fn contact_sphere(
&self,
sphere_center: &SVector<f64, D>,
sphere_radius: f64,
) -> Option<(SVector<f64, D>, f64)>
pub fn contact_sphere( &self, sphere_center: &SVector<f64, D>, sphere_radius: f64, ) -> Option<(SVector<f64, D>, f64)>
Analytical contact between a sphere and this half-space.
Returns Some((contact_point, depth)) if overlapping, None otherwise.
sphere_center is in world space.
Sourcepub fn contact_capsule(
&self,
capsule_pos: &SVector<f64, D>,
half_height: f64,
radius: f64,
axis: usize,
) -> Vec<(SVector<f64, D>, f64)>
pub fn contact_capsule( &self, capsule_pos: &SVector<f64, D>, half_height: f64, radius: f64, axis: usize, ) -> Vec<(SVector<f64, D>, f64)>
Analytical contact between a capsule and this half-space.
Returns contacts for both hemisphere centers (0, 1, or 2 contacts).
capsule_pos is the capsule’s world-space center.
Trait Implementations§
Source§impl<const D: usize> Shape<D> for HalfSpace<D>
impl<const D: usize> Shape<D> for HalfSpace<D>
Source§fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>
Support function for GJK compatibility.
Returns a point at HALFSPACE_EXTENT in the query direction (projected
onto the plane) or at -HALFSPACE_EXTENT * normal if direction points
into the solid. This is an approximation — use analytical contacts
for sphere/capsule/box instead.
Source§fn bounding_sphere(&self) -> (Point<D>, f64)
fn bounding_sphere(&self) -> (Point<D>, f64)
impl<const D: usize> Copy for HalfSpace<D>
Auto Trait Implementations§
impl<const D: usize> Freeze for HalfSpace<D>
impl<const D: usize> RefUnwindSafe for HalfSpace<D>
impl<const D: usize> Send for HalfSpace<D>
impl<const D: usize> Sync for HalfSpace<D>
impl<const D: usize> Unpin for HalfSpace<D>
impl<const D: usize> UnsafeUnpin for HalfSpace<D>
impl<const D: usize> UnwindSafe for HalfSpace<D>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§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.