diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-03-02 20:35:40 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-03-02 20:35:40 +0200 |
commit | 30df4064646fb429568474c0cdb2ee2ee08fd22e (patch) | |
tree | 2f444247ef993f2f3a346af747199cec3f2b9b46 /src/geometry.rs | |
parent | e1ba5ff36cefd602e64210dcfd0c4076c871e38c (diff) |
Clickable bugs!
Diffstat (limited to 'src/geometry.rs')
-rw-r--r-- | src/geometry.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/geometry.rs b/src/geometry.rs new file mode 100644 index 0000000..e9d534a --- /dev/null +++ b/src/geometry.rs @@ -0,0 +1,11 @@ +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Vec2d { + pub x: f64, + pub y: f64 +} + +impl Vec2d { + pub fn distance(&self, other: Vec2d) -> f64 { + ((other.x-self.x).powi(2) + (other.y-self.y).powi(2)).sqrt() + } +} |