diff options
Diffstat (limited to 'src/geometry.rs')
-rw-r--r-- | src/geometry.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/geometry.rs b/src/geometry.rs index be903d7..c49fe2a 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -8,8 +8,12 @@ pub struct Vec2d { impl Vec2d { pub fn distance(&self, other: Vec2d) -> f64 { - ((other.x-self.x).powi(2) + (other.y-self.y).powi(2)).sqrt() + self.distance_squared(other).sqrt() } + pub fn distance_squared(&self, other: Vec2d) -> f64 { + ((other.x-self.x).powi(2) + (other.y-self.y).powi(2)) + } + pub fn angle(&self) -> f64 { self.y.atan2(self.x) } |