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
|
use crate::geometry::vec::*;
use std::ops::*;
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
pub struct Point2d {
pub x: i8,
pub y: i8,
}
impl Point2d {
pub fn new(x: i8, y: i8) -> Point2d {
Point2d { x, y }
}
}
impl Add<Vec2d> for Point2d {
type Output = Self;
fn add(self, other: Vec2d) -> Self {
Point2d {
x: self.x.saturating_add(other.x),
y: self.y.saturating_add(other.y),
}
}
}
impl Sub for Point2d {
type Output = Vec2d;
fn sub(self, other: Self) -> Vec2d {
Vec2d {
x: self.x.saturating_sub(other.x),
y: self.y.saturating_sub(other.y),
}
}
}
|