From 49636c1c254a126cf386af879d5e5e71d6b8584f Mon Sep 17 00:00:00 2001 From: JackB-Ansys Date: Mon, 15 Jul 2024 16:03:04 +0100 Subject: [PATCH] Revert "Corrected calculation of arc length" This reverts commit eadbae2ac9c09395d1ee671ca7f65f755aed0407. --- src/ansys/motorcad/core/geometry.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ansys/motorcad/core/geometry.py b/src/ansys/motorcad/core/geometry.py index 5818d0675..2af1175f4 100644 --- a/src/ansys/motorcad/core/geometry.py +++ b/src/ansys/motorcad/core/geometry.py @@ -1164,7 +1164,19 @@ def length(self): float Length of arc """ - return abs(self.radius * radians(self.total_angle)) + radius, angle_1 = xy_to_rt(self.start.x, self.start.y) + radius, angle_2 = xy_to_rt(self.end.x, self.end.y) + + if self.radius == 0: + arc_angle = 0 + elif ((self.radius > 0) and (angle_1 > angle_2)) or ( + (self.radius < 0) and angle_2 < angle_1 + ): + arc_angle = angle_2 - (angle_1 - 360) + else: + arc_angle = angle_2 - angle_1 + + return self.radius * radians(arc_angle) def reverse(self): """Reverse Arc entity."""