parry3d/query/sat/
sat_cuboid_segment.rs

1use crate::math::{Isometry, Real, Vector};
2use crate::query::sat;
3use crate::shape::{Cuboid, Segment};
4
5/// Finds the best separating edge between a cuboid and a segment.
6///
7/// All combinations of edges from the cuboid and the segment are taken into
8/// account.
9#[cfg(feature = "dim3")]
10pub fn cuboid_segment_find_local_separating_edge_twoway(
11    cube1: &Cuboid,
12    segment2: &Segment,
13    pos12: &Isometry<Real>,
14) -> (Real, Vector<Real>) {
15    let x2 = pos12 * (segment2.b - segment2.a);
16
17    let axes = [
18        // Vector::{x, y ,z}().cross(y2)
19        Vector::new(0.0, -x2.z, x2.y),
20        Vector::new(x2.z, 0.0, -x2.x),
21        Vector::new(-x2.y, x2.x, 0.0),
22    ];
23
24    sat::cuboid_support_map_find_local_separating_edge_twoway(cube1, segment2, &axes, pos12)
25}
26
27/// Finds the best separating normal between a cuboid and a segment.
28///
29/// Only the normals of `segment1` are tested.
30#[cfg(feature = "dim2")]
31pub fn segment_cuboid_find_local_separating_normal_oneway(
32    segment1: &Segment,
33    shape2: &Cuboid,
34    pos12: &Isometry<Real>,
35) -> (Real, Vector<Real>) {
36    sat::point_cuboid_find_local_separating_normal_oneway(
37        segment1.a,
38        segment1.normal(),
39        shape2,
40        pos12,
41    )
42}