diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-05-01 11:15:14 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-05-01 11:15:14 +0200 |
commit | 934efcccaa5a82f993c13c91511afe1943caa3b4 (patch) | |
tree | 2544ba42a341de7a2b5d45cb74ad6928f0f11258 /src/geometry.rs | |
parent | a70b7befc08646ea92282fa30b12bae811f22203 (diff) |
Added escalating difficulty
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) } |