From af781837df4a4fb1df63103cdeb6a3dfbab7b9d4 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 4 Jun 2022 13:09:47 +0200 Subject: Renamed to VectorMath for now I still need to think about its place and how/if to address duplication from raymath.h --- Reader.cpp | 2 +- Utils.h | 30 ------------------------------ VectorMath.h | 30 ++++++++++++++++++++++++++++++ View.cpp | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 Utils.h create mode 100644 VectorMath.h diff --git a/Reader.cpp b/Reader.cpp index 165e049..edd7d36 100644 --- a/Reader.cpp +++ b/Reader.cpp @@ -9,7 +9,7 @@ #include "LongVector3.h" #include "Source.h" #include "Timeline.h" -#include "Utils.h" +#include "VectorMath.h" #include "Wreck.h" diff --git a/Utils.h b/Utils.h deleted file mode 100644 index 72eab4d..0000000 --- a/Utils.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include - - -template static auto test_z(int) -> decltype(decltype(T::z){}, std::true_type{}); -template static auto test_z(...) -> std::false_type; -template struct has_z : decltype(test_z(0)) {}; - - -template ::value, bool>::type=true> -T -dist(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)); -} - - -template ::value, bool>::type=true> -T -dist(const V& lhs, const V& rhs) -{ - return std::sqrt( - std::pow(lhs.x - rhs.x, 2) + - std::pow(lhs.y - rhs.y, 2)); -} diff --git a/VectorMath.h b/VectorMath.h new file mode 100644 index 0000000..72eab4d --- /dev/null +++ b/VectorMath.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + + +template static auto test_z(int) -> decltype(decltype(T::z){}, std::true_type{}); +template static auto test_z(...) -> std::false_type; +template struct has_z : decltype(test_z(0)) {}; + + +template ::value, bool>::type=true> +T +dist(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)); +} + + +template ::value, bool>::type=true> +T +dist(const V& lhs, const V& rhs) +{ + return std::sqrt( + std::pow(lhs.x - rhs.x, 2) + + std::pow(lhs.y - rhs.y, 2)); +} diff --git a/View.cpp b/View.cpp index dc36cce..4877ba4 100644 --- a/View.cpp +++ b/View.cpp @@ -11,7 +11,7 @@ #include "Grid.h" #include "Label.h" #include "Timeline.h" -#include "Utils.h" +#include "VectorMath.h" const Color BACKGROUND {8, 8, 50, 255}; -- cgit v1.1