parry3d/query/point/
point_halfspace.rs1use crate::math::{Real, Vector};
2use crate::query::{PointProjection, PointQuery};
3use crate::shape::{FeatureId, HalfSpace};
4
5impl PointQuery for HalfSpace {
6 #[inline]
7 fn project_local_point(&self, pt: Vector, solid: bool) -> PointProjection {
8 let d = self.normal.dot(pt);
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(&self, pt: Vector) -> (PointProjection, FeatureId) {
20 (self.project_local_point(pt, false), FeatureId::Face(0))
21 }
22
23 #[inline]
24 fn distance_to_local_point(&self, pt: Vector, solid: bool) -> Real {
25 let dist = self.normal.dot(pt);
26
27 if dist < 0.0 && solid {
28 0.0
29 } else {
30 dist
32 }
33 }
34
35 #[inline]
36 fn contains_local_point(&self, pt: Vector) -> bool {
37 self.normal.dot(pt) <= 0.0
38 }
39}