From 5505d2a209bbff124354d6d6ab5d8c0c1cf97c0d Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Tue, 24 Jan 2023 23:37:03 +0100 Subject: [PATCH] FIX: normalized angles of ARCs now always positive --- main.cpp | 10 ++++++---- main.h | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index bc8c25f..b6ce332 100644 --- a/main.cpp +++ b/main.cpp @@ -38,8 +38,12 @@ // Result is a new file "FILENAME.SCALED.elmt" or output on stdout // in both cases without the XML declaration-line // +// +// Change(s) for 0.4beta10 +// - fix: normalized angles for ARCs weren't always positive +// // Change(s) for 0.4beta9 -// - added mathmatically correct calculation for Min-Max-Values of ARC +// - added mathematically correct calculation for Min-Max-Values of ARC // // Change(s) for 0.4beta8 // - graphical element "arc": normalize "start" and "angle" to positive values @@ -111,7 +115,7 @@ #include "inc/pugixml/pugixml.hpp" #include "main.h" -const string sVersion = "0.4beta9"; +const string sVersion = "0.4beta10"; const int _debug_ = 0; const int _debug_points_ = 0; @@ -733,8 +737,6 @@ void DetermineArcMinMax(pugi::xml_node &node){ } return; } -/*****************************************************************************/ - /*****************************************************************************/ void DetermineMinMax(pugi::xml_node &node){ // no need to make a difference, what node it is: non-existing attributes return "0.0" diff --git a/main.h b/main.h index 8b2f55b..80773de 100644 --- a/main.h +++ b/main.h @@ -372,20 +372,20 @@ void PrintHelp(const string &s, const string &v){ /******************************************************************************/ void NormalizeArcVals(double &start, double &angle){ - int istart = round(std::fmod(start, 360.0)); - int iangle = round(std::fmod(angle, 360.0)); + int istart = (int)(round(start)) % 360; + int iangle = (int)(round(angle)) % 360; if (istart < 0) { // for example: // old values: start = -20; angle = 330; // new values: start = 340; angle = 330; - istart = (360 + istart) % 360; + istart = (istart + 360) % 360; iangle = iangle; } if (iangle < 0) { // for example: // old values: start = 350; angle = -330; // new values: start = 20; angle = 330; - istart = (istart + iangle) % 360; + istart = (istart + iangle + 360) % 360; iangle *= (-1); } start = istart;