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
pub mod halton_int;
pub mod interval_ai;
pub mod point;
pub mod polygon;
pub mod rpolygon;
pub mod vector2;

pub use crate::point::Point;
pub use crate::polygon::Polygon;
pub use crate::rpolygon::RPolygon;
pub use crate::vector2::Vector2;

/// TODO: rectangle
// mod rectangle;
// use crate::rectangle::Rect;

#[cfg(test)]
mod tests {
    use super::*;
    extern crate interval;
    use interval::ops::*;
    use interval::Interval;
    use quickcheck_macros::quickcheck;

    #[test]
    pub fn it_works() {
        let a = Point::<i32>::new(12, 23);
        let b = Vector2::<i32>::new(34, 45);
        println!("{:?}", a + b);
        println!("{:?}", a - b);

        let mut a = Point::<i32>::new(42, 53);
        a += b;
        a -= b;
        println!("{:?}", -a);

        let c = Point::<i32>::new(12, 23);
        let mm = Point::<Point<i32>>::new(a, c);
        println!("{:?}", mm);

        let x = Interval::<i32>::new(12, 23);
        // let y = Interval::<i32>::new(42, 53);
        println!("{:?}", x);

        // let _x = Interval::<i32>::new(12, 23);
        // let _y = Interval::<i32>::new(42, 53);
        // let r = Rect::<i32>::new(x, y);
        // println!("{:?}", r);

        // let mm = Matrix2::<i32>::new(a, b);
        // println!("{:?}", mm);
    }

    #[quickcheck]
    fn check_point(ax: u16, bx: u16) -> bool {
        let a = Point::<i32>::new(ax as i32, 23);
        let b = Vector2::<i32>::new(bx as i32, 45);
        a == (a - b) + b
    }
}