parry3d/query/intersection_test/
intersection_test_support_map_support_map.rs1use na::{self, Unit};
2
3use crate::math::{Isometry, Real, Vector};
4use crate::query::gjk::{self, CSOPoint, GJKResult, VoronoiSimplex};
5use crate::shape::SupportMap;
6
7pub fn intersection_test_support_map_support_map<G1, G2>(
9 pos12: &Isometry<Real>,
10 g1: &G1,
11 g2: &G2,
12) -> bool
13where
14 G1: ?Sized + SupportMap,
15 G2: ?Sized + SupportMap,
16{
17 intersection_test_support_map_support_map_with_params(
18 pos12,
19 g1,
20 g2,
21 &mut VoronoiSimplex::new(),
22 None,
23 )
24 .0
25}
26
27pub fn intersection_test_support_map_support_map_with_params<G1, G2>(
31 pos12: &Isometry<Real>,
32 g1: &G1,
33 g2: &G2,
34 simplex: &mut VoronoiSimplex,
35 init_dir: Option<Unit<Vector<Real>>>,
36) -> (bool, Unit<Vector<Real>>)
37where
38 G1: ?Sized + SupportMap,
39 G2: ?Sized + SupportMap,
40{
41 let dir = if let Some(init_dir) = init_dir {
42 init_dir
43 } else if let Some(init_dir) =
44 Unit::try_new(pos12.translation.vector, crate::math::DEFAULT_EPSILON)
45 {
46 init_dir
47 } else {
48 Vector::x_axis()
49 };
50
51 simplex.reset(CSOPoint::from_shapes(pos12, g1, g2, &dir));
52
53 match gjk::closest_points(pos12, g1, g2, 0.0, false, simplex) {
54 GJKResult::Intersection => (true, dir),
55 GJKResult::Proximity(dir) => (false, dir),
56 GJKResult::NoIntersection(dir) => (false, dir),
57 GJKResult::ClosestPoints(..) => unreachable!(),
58 }
59}