From a117836ed6bbbc750830a96647da88d5506e69f8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 14 Feb 2021 13:06:50 +0000 Subject: Construct an Arc from three points --- utility/maths.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'utility/maths.cpp') diff --git a/utility/maths.cpp b/utility/maths.cpp index 5cae411..e36c91e 100644 --- a/utility/maths.cpp +++ b/utility/maths.cpp @@ -39,15 +39,16 @@ normalize(float ang) return ang; } -Arc -create_arc(const glm::vec3 & centre3, const glm::vec3 & e0p, const glm::vec3 & e1p) +Arc::Arc(const glm::vec3 & centre3, const glm::vec3 & e0p, const glm::vec3 & e1p) : + Arc([&]() -> Arc { + const auto diffa = e0p - centre3; + const auto diffb = e1p - centre3; + const auto anga = flat_angle(diffa); + const auto angb = [&diffb, &anga]() { + const auto angb = flat_angle(diffb); + return (angb < anga) ? angb + two_pi : angb; + }(); + return {anga, angb}; + }()) { - const auto diffa = centre3 - e0p; - const auto diffb = centre3 - e1p; - const auto anga = flat_angle(diffa); - const auto angb = [&diffb, &anga]() { - const auto angb = flat_angle(diffb); - return (angb < anga) ? angb + two_pi : angb; - }(); - return {anga, angb}; } -- cgit v1.2.3