wrapNum function

double wrapNum(
  1. double x,
  2. Tuple2<double, double> range,
  3. [bool? includeMax]
)

Implementation

double wrapNum(double x, Tuple2<double, double> range, [bool? includeMax]) {
  var max = range.item2;
  var min = range.item1;
  var d = max - min;
  return x == max && includeMax != null ? x : ((x - min) % d + d) % d + min;
}