pub struct PointProjection {
pub is_inside: bool,
pub point: Vector,
}Expand description
The result of projecting a point onto a shape.
Vector projection finds the closest point on a shape’s surface to a given query point. This is fundamental for many geometric queries including distance calculation, collision detection, and surface sampling.
§Fields
- is_inside: Whether the query point is inside the shape
- point: The closest point on the shape’s surface
§Inside vs Outside
The is_inside flag indicates the query point’s location relative to the shape:
true: Query point is inside the shape (projection is on boundary)false: Query point is outside the shape (projection is nearest surface point)
§Solid Parameter
Most projection functions take a solid parameter:
solid = true: Shape is treated as solid (filled interior)solid = false: Shape is treated as hollow (surface only)
This affects is_inside calculation for points in the interior.
§Example
use parry3d::query::PointQuery;
use parry3d::shape::Ball;
use parry3d::math::{Vector, Pose};
let ball = Ball::new(5.0);
let ball_pos = Pose::translation(10.0, 0.0, 0.0);
// Project a point outside the ball
let outside_point = Vector::ZERO;
let proj = ball.project_point(&ball_pos, outside_point, true);
// Closest point on ball surface
assert_eq!(proj.point, Vector::new(5.0, 0.0, 0.0));
assert!(!proj.is_inside);
// Project a point inside the ball
let inside_point = Vector::new(10.0, 0.0, 0.0); // At center
let proj2 = ball.project_point(&ball_pos, inside_point, true);
assert!(proj2.is_inside);Fields§
§is_inside: boolWhether the query point was inside the shape.
true: Vector is in the interior (for solid shapes)false: Vector is outside the shape
point: VectorThe closest point on the shape’s surface to the query point.
If is_inside = true, this is the nearest point on the boundary.
If is_inside = false, this is the nearest surface point.
Implementations§
Source§impl PointProjection
impl PointProjection
Sourcepub fn transform_by(&self, pos: &Pose) -> Self
pub fn transform_by(&self, pos: &Pose) -> Self
Transforms self.point by pos.
Sourcepub fn is_inside_eps(&self, original_point: Vector, min_dist: f32) -> bool
pub fn is_inside_eps(&self, original_point: Vector, min_dist: f32) -> bool
Returns true if Self::is_inside is true or if the distance between the projected point and point is smaller than min_dist.
Trait Implementations§
Source§impl Clone for PointProjection
impl Clone for PointProjection
Source§fn clone(&self) -> PointProjection
fn clone(&self) -> PointProjection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PointProjection
impl Debug for PointProjection
Source§impl Default for PointProjection
impl Default for PointProjection
Source§fn default() -> PointProjection
fn default() -> PointProjection
impl Copy for PointProjection
Auto Trait Implementations§
impl Freeze for PointProjection
impl RefUnwindSafe for PointProjection
impl Send for PointProjection
impl Sync for PointProjection
impl Unpin for PointProjection
impl UnwindSafe for PointProjection
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<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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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.