function processSimplex(simplex, direction) {
  // we only need to handle to 1-simplex and 2-simplex
  if (simplex.length == 2) {
    // 1-simplex
    const a = simplex[1];
    const b = simplex[0];
    const AO = minus(simplex[1]);
    const AB = sub(b, a);
    // AO is in the same direction as AB
    if (dot(AO, AB) > 0) {
      // get the vector perpendicular to AB facing O
      set(direction, orth(AB, a));
    } else {
      set(direction, AO);
      // only A remains in the simplex
      simplex.shift();
    }
  } else {
    // 2-simplex
    const a = simplex[2]; // [a, b, c] = simplex
    const b = simplex[1];
    const c = simplex[0];
    const AB = sub(b, a);
    const AC = sub(c, a);
    const AO = minus(a);
    const ACB = orth(AB, AC); // the vector perpendicular to AB facing away from C
    const ABC = orth(AC, AB); // the vector perpendicular to AC facing away from B

    if (dot(ACB, AO) > 0) {
      if (dot(AB, AO) > 0) {
        // region 4
        set(direction, ACB);
        simplex.shift(); // simplex = [b, a]
      } else {
        // region 5
        set(direction, AO);
        simplex.splice(0, 2); // simplex = [a]
      }
    } else if (dot(ABC, AO) > 0) {
      if (dot(AC, AO) > 0) {
        // region 6
        set(direction, ABC);
        simplex.splice(1, 1); // simplex = [c, a]
      } else {
        // region 5 (again)
        set(direction, AO);
        simplex.splice(0, 2); // simplex = [a]
      }
    } // region 7
    else {
      return true;
    }
  }
  return false;
}
@param {number[][]} simplex
@param {number[]} direction
@returns {boolean}