From 21341f788654cfc806778fa34d09885431083d76 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 17 May 2022 19:36:15 +0200 Subject: Created a function for repeated distance calculations --- Utils-inl.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Utils-inl.h (limited to 'Utils-inl.h') diff --git a/Utils-inl.h b/Utils-inl.h new file mode 100644 index 0000000..01e0ca6 --- /dev/null +++ b/Utils-inl.h @@ -0,0 +1,24 @@ +#pragma once + +#include + + +template +T +dist2(const V& lhs, const V& rhs) +{ + return std::sqrt( + std::pow(lhs.x - rhs.x, 2) + + std::pow(lhs.y - rhs.y, 2)); +} + + +template +T +dist3(const V& lhs, const V& rhs) +{ + return std::sqrt( + std::pow(lhs.x - rhs.x, 2) + + std::pow(lhs.y - rhs.y, 2) + + std::pow(lhs.z - rhs.z, 2)); +} -- cgit v1.1