Class SeparatingAxisTheorem

java.lang.Object
technology.sola.engine.physics.utils.SeparatingAxisTheorem

@NullMarked public class SeparatingAxisTheorem extends Object
SeparatingAxisTheorem contains methods for checking whether two convex polygons are colliding or not.
  • Constructor Details

    • SeparatingAxisTheorem

      public SeparatingAxisTheorem()
  • Method Details

    • checkCollision

      public static @Nullable MinimumTranslationVector checkCollision(Vector2D[] shapeA, Vector2D[] shapeB)
      Checks for collisions between to shapes. If a collision is detected the MinimumTranslationVector will be returned. If no collision is found then null will be returned.
      Parameters:
      shapeA - the first array of points of a shape to check collisions with
      shapeB - the second array of points of a shape to check collisions with
      Returns:
      the MinimumTranslationVector if a collision was found or else null
    • checkCollision

      public static @Nullable MinimumTranslationVector checkCollision(Vector2D[] shape, Vector2D circleCenter, float radius)
      Checks for collisions between a shape and a circle. If a collision is detected the MinimumTranslationVector will be returned. If no collision is found then null will be returned.
      Parameters:
      shape - the array of points of a shape to check collisions with
      circleCenter - the circle center to check collisions with
      radius - the circle radius to check collisions with
      Returns:
      the MinimumTranslationVector if a collision was found or else null