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
use crate::math::{Isometry, Point, Real};
use std::mem;
#[derive(Debug, PartialEq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ClosestPoints {
Intersecting,
WithinMargin(Point<Real>, Point<Real>),
Disjoint,
}
impl ClosestPoints {
pub fn flip(&mut self) {
if let ClosestPoints::WithinMargin(ref mut p1, ref mut p2) = *self {
mem::swap(p1, p2)
}
}
#[must_use]
pub fn flipped(&self) -> Self {
if let ClosestPoints::WithinMargin(p1, p2) = *self {
ClosestPoints::WithinMargin(p2, p1)
} else {
*self
}
}
#[must_use]
pub fn transform_by(self, pos1: &Isometry<Real>, pos2: &Isometry<Real>) -> Self {
if let ClosestPoints::WithinMargin(p1, p2) = self {
ClosestPoints::WithinMargin(pos1 * p1, pos2 * p2)
} else {
self
}
}
}