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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use crate::math::{Isometry, Point, Real, Vector};
use na::{self, Unit};
use std::mem;
#[derive(Debug, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Contact {
pub point1: Point<Real>,
pub point2: Point<Real>,
pub normal1: Unit<Vector<Real>>,
pub normal2: Unit<Vector<Real>>,
pub dist: Real,
}
impl Contact {
#[inline]
pub fn new(
point1: Point<Real>,
point2: Point<Real>,
normal1: Unit<Vector<Real>>,
normal2: Unit<Vector<Real>>,
dist: Real,
) -> Self {
Contact {
point1,
point2,
normal1,
normal2,
dist,
}
}
}
impl Contact {
#[inline]
pub fn flip(&mut self) {
mem::swap(&mut self.point1, &mut self.point2);
mem::swap(&mut self.normal1, &mut self.normal2);
}
#[inline]
pub fn flipped(mut self) -> Self {
self.flip();
self
}
#[inline]
pub fn transform_by_mut(&mut self, pos1: &Isometry<Real>, pos2: &Isometry<Real>) {
self.point1 = pos1 * self.point1;
self.point2 = pos2 * self.point2;
self.normal1 = pos1 * self.normal1;
self.normal2 = pos2 * self.normal2;
}
pub fn transform1_by_mut(&mut self, pos: &Isometry<Real>) {
self.point1 = pos * self.point1;
self.normal1 = pos * self.normal1;
}
}