Module org.dyn4j

Class ExpandingSimplex

  • final class ExpandingSimplex
    extends java.lang.Object
    Represents a simplex that is progressively expanded by splitting the closest edge to the origin by adding new points.

    This class is used with the Epa class to maintain the state of the algorithm.

    Given the way the simplex is expanded, the winding can be computed initially and will never change.

    William Bittle
    • Constructor Summary

      Constructor Description
      ExpandingSimplex​(java.util.List<Vector2> simplex)
      Minimal constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void expand​(Vector2 point)
      Expands the simplex by the given point.
      ExpandingSimplexEdge getClosestEdge()
      Returns the edge on the simplex that is closest to the origin.
      protected int getWinding​(java.util.List<Vector2> simplex)
      Returns the winding of the given simplex.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExpandingSimplex

        public ExpandingSimplex​(java.util.List<Vector2> simplex)
        Minimal constructor.
        simplex - the starting simplex from GJK
    • Method Detail

      • getWinding

        protected final int getWinding​(java.util.List<Vector2> simplex)
        Returns the winding of the given simplex.

        Returns -1 if the winding is Clockwise.
        Returns 1 if the winding is Counter-Clockwise.

        This method will continue checking all edges until an edge is found whose cross product is less than or greater than zero.

        This is used to get the correct edge normal of the simplex.

        simplex - the simplex
        int the winding
      • expand

        public final void expand​(Vector2 point)
        Expands the simplex by the given point.

        Removes the closest edge to the origin and adds two new edges using the given point and the removed edge's vertices.

        point - the new point