parry3d/query/intersection_test/
intersection_test_ball_point_query.rs1use crate::math::{Isometry, Point, Real};
2use crate::query::PointQuery;
3use crate::shape::Ball;
4
5pub fn intersection_test_ball_point_query<P: ?Sized + PointQuery>(
7 pos12: &Isometry<Real>,
8 ball1: &Ball,
9 point_query2: &P,
10) -> bool {
11 intersection_test_point_query_ball(&pos12.inverse(), point_query2, ball1)
12}
13
14pub fn intersection_test_point_query_ball<P: ?Sized + PointQuery>(
16 pos12: &Isometry<Real>,
17 point_query1: &P,
18 ball2: &Ball,
19) -> bool {
20 let local_p2_1 = Point::from(pos12.translation.vector);
21 let proj = point_query1.project_local_point(&local_p2_1, true);
22 proj.is_inside || (local_p2_1 - proj.point).norm_squared() <= ball2.radius * ball2.radius
23}