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) {
  this.rotation.extractBasis(xAxis, yAxis, zAxis);

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

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

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

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

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

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