From f88f48f64f223085f97f0f2945298f9023d09693 Mon Sep 17 00:00:00 2001 From: Ed Williams Date: Tue, 27 Feb 2024 10:38:05 -1000 Subject: [PATCH] Change the calculation of the b parameter of the hyperbolic arc (#12467) * Change the calculation of the b parameter of the hyperbolic arc so that it does not give 0/0 when cos(phi) = 0 This gave problems if the first two points defined in the sketcher had the same x-coordinate. --- .../Gui/DrawSketchHandlerArcOfHyperbola.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfHyperbola.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfHyperbola.h index 4b33bd453b..672f7698a4 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfHyperbola.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArcOfHyperbola.h @@ -102,8 +102,9 @@ public: double angleatpoint = acosh(((onSketchPos.x - centerPoint.x) * cos(phi) + (onSketchPos.y - centerPoint.y) * sin(phi)) / a); - double b = (onSketchPos.y - centerPoint.y - a * cosh(angleatpoint) * sin(phi)) - / (sinh(angleatpoint) * cos(phi)); + double b = ((onSketchPos.y - centerPoint.y) * cos(phi) + - (onSketchPos.x - centerPoint.x) * sin(phi)) + / sinh(angleatpoint); if (!boost::math::isnan(b)) { for (int i = 15; i >= -15; i--) { @@ -140,8 +141,9 @@ public: double angleatstartingpoint = acosh(((startingPoint.x - centerPoint.x) * cos(phi) + (startingPoint.y - centerPoint.y) * sin(phi)) / a); - double b = (startingPoint.y - centerPoint.y - a * cosh(angleatstartingpoint) * sin(phi)) - / (sinh(angleatstartingpoint) * cos(phi)); + double b = ((startingPoint.y - centerPoint.y) * cos(phi) + - (startingPoint.x - centerPoint.x) * sin(phi)) + / sinh(angleatstartingpoint); double startAngle = angleatstartingpoint; @@ -240,8 +242,10 @@ public: double angleatstartingpoint = acosh(((startingPoint.x - centerPoint.x) * cos(phi) + (startingPoint.y - centerPoint.y) * sin(phi)) / a); - double b = (startingPoint.y - centerPoint.y - a * cosh(angleatstartingpoint) * sin(phi)) - / (sinh(angleatstartingpoint) * cos(phi)); + + double b = ((startingPoint.y - centerPoint.y) * cos(phi) + - (startingPoint.x - centerPoint.x) * sin(phi)) + / sinh(angleatstartingpoint); double startAngle = angleatstartingpoint;