From 63425aea8fadec35857d059a0cdc869863ddbaf5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Feb 2021 20:16:33 +0000 Subject: Calculate the candidate radii to join to point+direction angle pairs Returns a pair of the left and right variants. --- utility/maths.cpp | 13 +++++++++++++ utility/maths.h | 1 + 2 files changed, 14 insertions(+) diff --git a/utility/maths.cpp b/utility/maths.cpp index 75346a0..543c887 100644 --- a/utility/maths.cpp +++ b/utility/maths.cpp @@ -84,6 +84,19 @@ find_arc_centre(glm::vec2 as, glm::vec2 ad, glm::vec2 bs, glm::vec2 bd) throw std::runtime_error("no intersection"); } +std::pair +find_arcs_radius(glm::vec2 start, float entrys, glm::vec2 end, float entrye) +{ + const auto getrad = [&](float leftOrRight) { + const auto perps = entrys + leftOrRight; + const auto perpe = entrye + leftOrRight; + const glm::vec2 ad {std::sin(perps), std::cos(perps)}; + const glm::vec2 bd {std::sin(perpe), std::cos(perpe)}; + return find_arcs_radius(start, ad, end, bd); + }; + return {getrad(-half_pi), getrad(half_pi)}; +} + float find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd) { diff --git a/utility/maths.h b/utility/maths.h index b0048c3..89cb7cb 100644 --- a/utility/maths.h +++ b/utility/maths.h @@ -55,6 +55,7 @@ float normalize(float ang); std::pair find_arc_centre(glm::vec2 start, float entrys, glm::vec2 end, float entrye); std::pair find_arc_centre(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd); +std::pair 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); #endif -- cgit v1.2.3