parry3d/query/point/
point_halfspace.rs1use crate::math::{Point, Real};
2use crate::query::{PointProjection, PointQuery};
3use crate::shape::{FeatureId, HalfSpace};
4
5impl PointQuery for HalfSpace {
6 #[inline]
7 fn project_local_point(&self, pt: &Point<Real>, solid: bool) -> PointProjection {
8 let d = self.normal.dot(&pt.coords);
9 let inside = d <= 0.0;
10
11 if inside && solid {
12 PointProjection::new(true, *pt)
13 } else {
14 PointProjection::new(inside, *pt + (-*self.normal * d))
15 }
16 }
17
18 #[inline]
19 fn project_local_point_and_get_feature(
20 &self,
21 pt: &Point<Real>,
22 ) -> (PointProjection, FeatureId) {
23 (self.project_local_point(pt, false), FeatureId::Face(0))
24 }
25
26 #[inline]
27 fn distance_to_local_point(&self, pt: &Point<Real>, solid: bool) -> Real {
28 let dist = self.normal.dot(&pt.coords);
29
30 if dist < 0.0 && solid {
31 0.0
32 } else {
33 dist
35 }
36 }
37
38 #[inline]
39 fn contains_local_point(&self, pt: &Point<Real>) -> bool {
40 self.normal.dot(&pt.coords) <= 0.0
41 }
42}