From 491cdb55efed10a31be0d21ede5bbfe289fb83ca Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Feb 2021 20:07:18 +0000 Subject: find_arc_centre given vectors --- utility/maths.cpp | 5 +++++ utility/maths.h | 1 + 2 files changed, 6 insertions(+) diff --git a/utility/maths.cpp b/utility/maths.cpp index bda6ea6..866097a 100644 --- a/utility/maths.cpp +++ b/utility/maths.cpp @@ -69,7 +69,12 @@ find_arc_centre(glm::vec2 as, float entrys, glm::vec2 bs, float entrye) const auto perpe = entrye - half_pi; const glm::vec2 ad {std::sin(perps), std::cos(perps)}; const glm::vec2 bd {std::sin(perpe), std::cos(perpe)}; + return find_arc_centre(as, ad, bs, bd); +} +std::pair +find_arc_centre(glm::vec2 as, glm::vec2 ad, glm::vec2 bs, glm::vec2 bd) +{ const auto det = bd.x * ad.y - bd.y * ad.x; if (det != 0) { // near parallel line will yield noisy results const auto d = bs - as; diff --git a/utility/maths.h b/utility/maths.h index 47b95a3..2ce5d94 100644 --- a/utility/maths.h +++ b/utility/maths.h @@ -54,5 +54,6 @@ arc_length(const Arc & arc) 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); #endif -- cgit v1.2.3