From 49cfebf74e97ccc88d2d6a459172cb2a17e545b8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 21 Mar 2024 20:05:56 +0000 Subject: vector_yaw only needs 2 dimensions --- lib/maths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/maths.cpp') diff --git a/lib/maths.cpp b/lib/maths.cpp index 68662fc..bf17204 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -76,7 +76,7 @@ rotate_yp(Rotation2D a) } float -vector_yaw(const Direction3D & diff) +vector_yaw(const Direction2D & diff) { return std::atan2(diff.x, diff.y); } -- cgit v1.2.3 From 4571ce1b4cac2ab9bf2454ed06d0d787604d62fa Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 21 Mar 2024 20:23:44 +0000 Subject: Add helper constructors to Arc * Two angles, wraps logic ensuring b after a * Two vector directions * Centre and two endpoints, in at least 2 dimensions, uses .xy() --- lib/maths.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/maths.cpp') diff --git a/lib/maths.cpp b/lib/maths.cpp index bf17204..51e27fe 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -4,6 +4,11 @@ #include #include +Arc::Arc(const RelativePosition2D & dir0, const RelativePosition2D & dir1) : + Arc {vector_yaw(dir0), vector_yaw(dir1)} { } + +Arc::Arc(const Angle anga, const Angle angb) : pair {anga, (angb < anga) ? angb + two_pi : angb} { } + glm::mat4 flat_orientation(const Direction3D & diff) { -- cgit v1.2.3