intersectsPlane method

dynamic intersectsPlane(
  1. dynamic plane
)

Reference: Testing Box Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.3)

Implementation

intersectsPlane(plane) {
  rotation.extractBasis(xAxis, yAxis, zAxis);

  // compute the projection interval radius of this OBB onto L(t) = this->center + t * p.normal;

  var r = halfSize.x * Math.abs(plane.normal.dot(xAxis)) +
      halfSize.y * Math.abs(plane.normal.dot(yAxis)) +
      halfSize.z * Math.abs(plane.normal.dot(zAxis));

  // compute distance of the OBB's center from the plane

  var d = plane.normal.dot(center) - plane.constant;

  // Intersection occurs when distance d falls within [-r,+r] interval

  return Math.abs(d) <= r;
}