From ba05ff7645b3d5cabbbd72c8595ad8232dd4d6d3 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sat, 8 Apr 2023 03:41:43 +0200 Subject: [PATCH] added distance to Pos3 --- src/lib/Pos3.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/Pos3.hx b/src/lib/Pos3.hx index 104d245..75ef0a7 100644 --- a/src/lib/Pos3.hx +++ b/src/lib/Pos3.hx @@ -104,4 +104,8 @@ abstract Pos3(Vec3) from Vec3 to Vec3{ z: Math.fround(this.z) }); } + + public function distance(rhs:Pos3):Float { + return Math.sqrt(Math.pow(this.x - rhs.x, 2) + Math.pow(this.y - rhs.y, 2) + Math.pow(this.z - rhs.z, 2)); + } }