From 3f5492b2bb67326be43cd7c5ba02ccf0ba1ae0e3 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 19 Apr 2022 21:27:56 +0200 Subject: Refile for merging repos --- src/geometry/vec.rs | 62 ----------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/geometry/vec.rs (limited to 'src/geometry/vec.rs') diff --git a/src/geometry/vec.rs b/src/geometry/vec.rs deleted file mode 100644 index 375a0f9..0000000 --- a/src/geometry/vec.rs +++ /dev/null @@ -1,62 +0,0 @@ -use std::ops::*; - -#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)] -pub struct Vec2d { - pub x: i8, - pub y: i8, -} - -impl Vec2d { - pub const fn new(x: i8, y: i8) -> Vec2d { - Vec2d { x, y } - } - pub fn magnitude_squared(&self) -> i8 { - self.x - .saturating_pow(2) - .saturating_add(self.y.saturating_pow(2)) - } -} - -impl Add for Vec2d { - type Output = Self; - - fn add(self, other: Self) -> Self { - Vec2d { - x: self.x.saturating_add(other.x), - y: self.y.saturating_add(other.y), - } - } -} - -impl Sub for Vec2d { - type Output = Self; - - fn sub(self, other: Self) -> Self { - Vec2d { - x: self.x.saturating_sub(other.x), - y: self.y.saturating_sub(other.y), - } - } -} - -impl Mul for Vec2d { - type Output = Self; - - fn mul(self, other: i8) -> Self { - Vec2d { - x: self.x.saturating_mul(other), - y: self.y.saturating_mul(other), - } - } -} - -impl Neg for Vec2d { - type Output = Self; - - fn neg(self) -> Self { - Vec2d { - x: -self.x, - y: -self.y, - } - } -} -- cgit v1.2.3