summaryrefslogtreecommitdiff
path: root/src/geometry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/geometry.rs')
-rw-r--r--src/geometry.rs11
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()
+ }
+}