logo
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
use super::*;

impl<T> ValidShape<T> for Triangle<T>
where
    T: Num + PartialOrd + Clone,
{
    fn is_empty_under_thousand(&self, thousand: T) -> bool {
        let a = Vector::from_2_points(self.vertex[0].clone(), self.vertex[1].clone());
        let b = Vector::from_2_points(self.vertex[1].clone(), self.vertex[2].clone());
        a.dx * b.dy - a.dy * b.dx < thousand
    }
}

impl<T> ValidShape<T> for Square<T>
where
    T: Zero + PartialOrd,
{
    fn is_empty_under_thousand(&self, thousand: T) -> bool {
        self.side <= thousand
    }
}

impl<T> ValidShape<T> for Rectangle<T>
where
    T: Zero + PartialOrd,
{
    fn is_empty_under_thousand(&self, thousand: T) -> bool {
        self.side.0 <= thousand && self.side.1 <= thousand
    }
}