testSepAxis method

double? testSepAxis(
  1. Vec3 axis,
  2. ConvexPolyhedron hullB,
  3. Vec3 posA,
  4. Quaternion quatA,
  5. Vec3 posB,
  6. Quaternion quatB,
)

Test separating axis against two hulls. Both hulls are projected onto the axis and the overlap size is returned if there is one. @return The overlap depth, or FALSE if no penetration.

Implementation

double? testSepAxis(
  Vec3 axis,
  ConvexPolyhedron hullB,
  Vec3 posA,
  Quaternion quatA,
  Vec3 posB,
  Quaternion quatB
){
  final hullA = this;
  final List<double> maxminA = [0,0];
  final List<double> maxminB = [0,0];
  ConvexPolyhedron.project(hullA, axis, posA, quatA, maxminA);
  ConvexPolyhedron.project(hullB, axis, posB, quatB, maxminB);
  final maxA = maxminA[0];
  final minA = maxminA[1];
  final maxB = maxminB[0];
  final minB = maxminB[1];
  if (maxA < minB || maxB < minA) {
    return null; // Separated
  }
  final double d0 = maxA - minB;
  final d1 = maxB - minA;
  final double depth = d0 < d1 ? d0 : d1;
  return depth;
}