getNormalAndDepth static method
Implementation
static ({Vector2 normal, double depth}) getNormalAndDepth(
List<Vector2> verticesA,
List<Vector2> verticesB, {
bool insverted = false,
}) {
Vector2 normal = Vector2.zero();
double depth = double.maxFinite;
for (int i = 0; i < verticesA.length; i++) {
Vector2 va = verticesA[i];
Vector2 vb = verticesA[(i + 1) % verticesA.length];
Vector2 edge = vb - va;
Vector2 axis = Vector2(-edge.y, edge.x);
axis = axis.normalized();
final pA = projectVertices(insverted ? verticesB : verticesA, axis);
final pB = projectVertices(insverted ? verticesA : verticesB, axis);
double axisDepth = min(pB.max - pA.min, pA.max - pB.min);
if (axisDepth < depth) {
depth = axisDepth;
normal = axis;
}
}
return (normal: normal, depth: depth);
}