pub struct PointProjection {
pub is_inside: bool,
pub point: Point<f32>,
}Expand description
The result of projecting a point onto a shape.
Point 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 nalgebra::{Point3, Isometry3};
let ball = Ball::new(5.0);
let ball_pos = Isometry3::translation(10.0, 0.0, 0.0);
// Project a point outside the ball
let outside_point = Point3::origin();
let proj = ball.project_point(&ball_pos, &outside_point, true);
// Closest point on ball surface
assert_eq!(proj.point, Point3::new(5.0, 0.0, 0.0));
assert!(!proj.is_inside);
// Project a point inside the ball
let inside_point = Point3::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: Point is in the interior (for solid shapes)false: Point is outside the shape
point: Point<f32>The 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: &Isometry<f32>) -> Self
pub fn transform_by(&self, pos: &Isometry<f32>) -> Self
Transforms self.point by pos.
Trait Implementations§
Source§impl Clone for PointProjection
impl Clone for PointProjection
Source§fn clone(&self) -> PointProjection
fn clone(&self) -> PointProjection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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> 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>
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 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>
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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.