1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use na::RealField;
use crate::interpolation::RigidMotion;
use crate::query::{self, TOIDispatcher, Unsupported, TOI};
use crate::shape::{Ball, Shape};
pub fn nonlinear_time_of_impact<N: RealField>(
dispatcher: &dyn TOIDispatcher<N>,
motion1: &dyn RigidMotion<N>,
g1: &dyn Shape<N>,
motion2: &dyn RigidMotion<N>,
g2: &dyn Shape<N>,
max_toi: N,
target_distance: N,
) -> Result<Option<TOI<N>>, Unsupported> {
if let (Some(b1), Some(b2)) = (g1.as_shape::<Ball<N>>(), g2.as_shape::<Ball<N>>()) {
Ok(query::nonlinear_time_of_impact_ball_ball(
motion1,
b1,
motion2,
b2,
max_toi,
target_distance,
))
} else if let (Some(s1), Some(s2)) = (g1.as_support_map(), g2.as_support_map()) {
Ok(query::nonlinear_time_of_impact_support_map_support_map(
motion1,
s1,
motion2,
s2,
max_toi,
target_distance,
))
} else if let Some(c1) = g1.as_composite_shape() {
Ok(query::nonlinear_time_of_impact_composite_shape_shape(
dispatcher,
motion1,
c1,
motion2,
g2,
max_toi,
target_distance,
))
} else if let Some(c2) = g2.as_composite_shape() {
Ok(query::nonlinear_time_of_impact_shape_composite_shape(
dispatcher,
motion1,
g1,
motion2,
c2,
max_toi,
target_distance,
))
} else {
Err(Unsupported)
}
}