exponentialFilter static method
Implementation
static double exponentialFilter(double newValue, double previousValue,
double filterFactor, bool isCircular) {
double newValueP = newValue;
if (isCircular) {
if ((newValueP - previousValue).abs() > 180) {
if (previousValue < 180 && newValue > 180) {
newValueP -= 360;
} else if (previousValue > 180 && newValueP < 180) {
newValueP += 360;
}
}
}
final filteredValue =
(newValueP * filterFactor) + (previousValue * (1.0 - filterFactor));
return filteredValue;
}