constantDeviation property

double get constantDeviation

How far the field strays from constant, as max(|value - mean|) / max(mean) over every sampled direction and channel. Zero for a perfectly uniform environment.

Implementation

double get constantDeviation {
  final scale = math.max(math.max(mean.x, mean.y), mean.z);
  if (scale <= 0.0) return 0.0;
  var worst = 0.0;
  for (final (value, m) in <(double, double)>[
    (minimum.x, mean.x),
    (minimum.y, mean.y),
    (minimum.z, mean.z),
    (maximum.x, mean.x),
    (maximum.y, mean.y),
    (maximum.z, mean.z),
  ]) {
    worst = math.max(worst, (value - m).abs());
  }
  return worst / scale;
}