Skip to content

Commit

Permalink
FIX: normalized angles of ARCs now always positive
Browse files Browse the repository at this point in the history
  • Loading branch information
plc-user committed Jan 24, 2023
1 parent 8e4a5b7 commit 5505d2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5505d2a

Please sign in to comment.