fuzzyEquals static method

bool fuzzyEquals(
  1. Vec2D a,
  2. Vec2D b
)

Implementation

static bool fuzzyEquals(Vec2D a, Vec2D b) {
  double a0 = a[0], a1 = a[1];
  double b0 = b[0], b1 = b[1];
  return (a0 - b0).abs() <= epsilon * max(1.0, max(a0.abs(), b0.abs())) &&
      (a1 - b1).abs() <= epsilon * max(1.0, max(a1.abs(), b1.abs()));
}