1use lmaths::*;
3use crate::Shape;
4
5#[derive(Clone, Debug, Copy)]
7pub struct SupportPoint {
8    pub v: Vector2,
10    sup_a: Vector2,
12    sup_b: Vector2,
14}
15
16#[allow(dead_code)]
17impl SupportPoint {
18    pub fn new() -> Self {
20        Self {
21            v: Vector2::ZERO,
22            sup_a: Vector2::ZERO,
23            sup_b: Vector2::ZERO,
24        }
25    }
26
27    pub fn from_minkowski (left:&dyn Shape, right:&dyn Shape, direction:Vector2) -> Self {
29        let l = left.support_point(direction);
30        let r = right.support_point(-direction);
31
32        Self {
33            v: (l - r),
34            sup_a: l,
35            sup_b: r,
36        }
37    }
38}
39
40impl std::ops::Sub<Vector2> for SupportPoint {
41    type Output = Self;
42
43    fn sub(self, rhs:Vector2) -> Self {
44        SupportPoint {
45            v: self.v - rhs,
46            sup_a: self.sup_a,
47            sup_b: self.sup_b,
48        }
49    }
50}