Ref T709, improved normalization and space pressed handling, unit test

This commit is contained in:
Klaus Basan
2019-08-09 23:41:01 +02:00
committed by Mat Sutcliffe
parent cdffc11c99
commit add649c321
4 changed files with 88 additions and 15 deletions

View File

@@ -92,6 +92,16 @@ namespace BlackMisc
return tokens;
}
//! Normalize value to range start -> end (like for +-180degrees)
inline double normalizeValue(const double value, const double start, const double end)
{
// https://stackoverflow.com/questions/1628386/normalise-orientation-between-0-and-360
if (value >= start && value <= end) { return value; }
const double width = end - start ;
const double offsetValue = value - start; // value relative to 0
return (offsetValue - (floor(offsetValue / width) * width)) + start ;
}
//! ACF properties
struct AcfProperties
{