Module org.dyn4j

Class Separation


  • public class Separation
    extends java.lang.Object
    Represents a Separation of one Convex Shape between another.

    The separation normal should always be normalized.

    Since:
    1.0.0
    Version:
    3.0.2
    Author:
    William Bittle
    • Field Detail

      • normal

        protected Vector2 normal
        The normalized axis of separation
      • distance

        protected double distance
        The separating distance along the axis
      • point1

        protected Vector2 point1
        The closest point on the first Convex Shape to the second
      • point2

        protected Vector2 point2
        The closest point on the second Convex Shape to the first
    • Constructor Detail

      • Separation

        public Separation()
        Default constructor.
      • Separation

        public Separation​(Vector2 normal,
                          double distance,
                          Vector2 point1,
                          Vector2 point2)
        Full constructor.
        Parameters:
        normal - the penetration normal
        distance - the separation distance
        point1 - the closest point on the first Convex Shape to the second
        point2 - the closest point on the second Convex Shape to the first
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clear

        public void clear()
        Clears the separation information.
      • getNormal

        public Vector2 getNormal()
        Returns the separation normal.
        Returns:
        Vector2
      • getDistance

        public double getDistance()
        Returns the separation distance.
        Returns:
        double
      • setNormal

        public void setNormal​(Vector2 normal)
        Sets the separation normal.

        Must be normalized.

        Parameters:
        normal - the separation normal
      • setDistance

        public void setDistance​(double distance)
        Sets the separation distance.
        Parameters:
        distance - the separation distance
      • setPoint1

        public void setPoint1​(Vector2 point1)
        Sets the closest point on the first Convex Shape.
        Parameters:
        point1 - the closest point on the first Convex Shape
      • setPoint2

        public void setPoint2​(Vector2 point2)
        Sets the closest point on the second Convex Shape.
        Parameters:
        point2 - the closest point on the second Convex Shape