-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve range reduction algorithm #169
base: main
Are you sure you want to change the base?
Conversation
…all angle tests locally
Codecov Report
@@ Coverage Diff @@
## main #169 +/- ##
==========================================
+ Coverage 79.86% 79.88% +0.02%
==========================================
Files 93 93
Lines 7448 7447 -1
==========================================
+ Hits 5948 5949 +1
+ Misses 1500 1498 -2
|
@@ -1,5 +1,5 @@ | |||
/// Apache License 2.0 | |||
|
|||
#include <cmath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply for consistency:
#include <cmath> | |
#include <cmath> | |
|
||
const Real range = aRangeUpperBound - aRangeLowerBound; | ||
const Real excessValue = std::fmod(aValue - aRangeLowerBound, aRangeUpperBound - aRangeLowerBound); | ||
const Real adjestedRangeValue = aRangeLowerBound + excessValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const Real adjestedRangeValue = aRangeLowerBound + excessValue; | |
const Real adjustedRangeValue = aRangeLowerBound + excessValue; |
|
||
while (value < aRangeLowerBound | ||
) // [TBM] This is a STUPID implementation: just used as a logic placeholder... should be improved ASAP | ||
if ((adjestedRangeValue >= aRangeLowerBound) && (adjestedRangeValue < aRangeUpperBound)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ((adjestedRangeValue >= aRangeLowerBound) && (adjestedRangeValue < aRangeUpperBound)) | |
if ((adjustedRangeValue >= aRangeLowerBound) && (adjustedRangeValue < aRangeUpperBound)) |
{ | ||
value += range; | ||
return adjestedRangeValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return adjestedRangeValue; | |
return adjustedRangeValue; |
|
||
while (value >= aRangeUpperBound | ||
) // [TBM] This is a STUPID implementation: just used as a logic placeholder... should be improved ASAP | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an else
block, since the if
block returns.
{ | ||
value -= range; | ||
/*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment block style is likely different from the rest of the codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits. yeah I agree this is a bit gross :/ let me think if there's a better way to deal with the rounding issues.
@@ -61,7 +62,7 @@ bool Angle::operator==(const Angle& anAngle) const | |||
{ | |||
return false; | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -356,7 +357,7 @@ Real Angle::in(const Angle::Unit& aUnit) const | |||
return this->accessValue(); | |||
} | |||
|
|||
return this->accessValue() * Angle::SIRatio(unit_) / Angle::SIRatio(aUnit); | |||
return (this->accessValue() * Angle::SIRatio(unit_) / Angle::SIRatio(aUnit)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (this->accessValue() * Angle::SIRatio(unit_) / Angle::SIRatio(aUnit)); | |
return this->accessValue() * Angle::SIRatio(unit_) / Angle::SIRatio(aUnit); |
@@ -732,24 +733,20 @@ Real Angle::ReduceRange(const Real& aValue, const Real& aRangeLowerBound, const | |||
"Lower bound [{}] greater than or equal to upper bound [{}].", aRangeLowerBound, aRangeUpperBound | |||
); | |||
} | |||
// this line handles some rounding error albeit in a way that doesnt pass the smell test... | |||
Real value = aValue + 10.0 - 10.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real value = aValue + 10.0 - 10.0; | |
const Real value = aValue + 10.0 - 10.0; |
No description provided.