diff options
author | Aki <please@ignore.pl> | 2022-05-17 19:36:15 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-05-17 19:50:04 +0200 |
commit | 21341f788654cfc806778fa34d09885431083d76 (patch) | |
tree | 313cf15a37ed1f34b5807874a2a03ca8f421aeeb /Utils-inl.h | |
parent | e9115c36c3580b209f7b53692deb52905125256e (diff) | |
download | derelict-21341f788654cfc806778fa34d09885431083d76.zip derelict-21341f788654cfc806778fa34d09885431083d76.tar.gz derelict-21341f788654cfc806778fa34d09885431083d76.tar.bz2 |
Created a function for repeated distance calculations
Diffstat (limited to 'Utils-inl.h')
-rw-r--r-- | Utils-inl.h | 24 |
1 files changed, 24 insertions, 0 deletions
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 <cmath> + + +template <typename V, typename T> +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 <typename V, typename T> +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)); +} |