From a0847c22c737f9950a13ff7b34fe585feda18273 Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Tue, 27 Jan 2026 16:19:53 +0100 Subject: [PATCH] Sketcher: fix logic flaw in ConstraintLineByAngle --- src/Mod/Sketcher/Gui/Utils.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 18d797bf6c..1a79db76d7 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -750,16 +750,11 @@ void SketcherGui::ConstraintToAttachment( void SketcherGui::ConstraintLineByAngle(int geoId, double angle, App::DocumentObject* obj) { using std::numbers::pi; - double angleModPi = std::fmod(angle, pi); - double angleModHalfPi = std::fmod(angle, pi / 2); - if (fabs(angleModPi - pi) < Precision::Confusion() - || fabs(angleModPi + pi) < Precision::Confusion() - || fabs(angleModPi) < Precision::Confusion()) { + if (fabs(std::remainder(angle, pi)) < Precision::Confusion()) { Gui::cmdAppObjectArgs(obj, "addConstraint(Sketcher.Constraint('Horizontal',%d)) ", geoId); } - else if (fabs(angleModHalfPi - pi / 2) < Precision::Confusion() - || fabs(angleModHalfPi + pi / 2) < Precision::Confusion()) { + else if (fabs(std::remainder(angle, pi / 2)) < Precision::Confusion()) { Gui::cmdAppObjectArgs(obj, "addConstraint(Sketcher.Constraint('Vertical',%d)) ", geoId); } else {