summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-18 14:04:23 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-18 14:04:23 +0000
commit9c2fce90b58b65b6c52802657fe5aff602d4afb2 (patch)
treedb3086b2f851b145375c6d1ccc92618b34c0f022
parentPair support for streams (diff)
downloadilt-9c2fce90b58b65b6c52802657fe5aff602d4afb2.tar.bz2
ilt-9c2fce90b58b65b6c52802657fe5aff602d4afb2.tar.xz
ilt-9c2fce90b58b65b6c52802657fe5aff602d4afb2.zip
Helper for midpoint of pair
-rw-r--r--lib/maths.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/maths.h b/lib/maths.h
index 1c07baa..5bb69d3 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -3,6 +3,7 @@
#include <cmath>
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
+#include <numeric>
#include <utility>
struct Arc : public std::pair<float, float> {
@@ -130,6 +131,13 @@ std::pair<glm::vec2, bool> find_arc_centre(glm::vec2 start, glm::vec2 ad, glm::v
std::pair<float, float> find_arcs_radius(glm::vec2 start, float entrys, glm::vec2 end, float entrye);
float find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd);
+template<typename T>
+auto
+midpoint(const std::pair<T, T> & v)
+{
+ return std::midpoint(v.first, v.second);
+}
+
// Conversions
template<typename T>
inline constexpr auto