Module org.dyn4j

Class Constraint

  • All Implemented Interfaces:
    Shiftable
    Direct Known Subclasses:
    ContactConstraint, Joint

    public abstract class Constraint
    extends java.lang.Object
    implements Shiftable
    Represents some physical constraint between a pair of Bodys.
    Since:
    1.0.0
    Version:
    3.2.0
    Author:
    William Bittle
    • Field Detail

      • body1

        protected final Body body1
        The first Body
      • body2

        protected final Body body2
        The second Body
      • onIsland

        boolean onIsland
        Whether the Constraint has been added to an Island or not
      • world

        World world
        The world the constraint has been added to

        This is really only used for Joints to determine if they have been added to a world already.

    • Constructor Detail

      • Constraint

        public Constraint​(Body body1,
                          Body body2)
        Full constructor.
        Parameters:
        body1 - the first participating Body
        body2 - the second participating Body
        Throws:
        java.lang.NullPointerException - if body1 or body2 is null
    • Method Detail

      • toString

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

        public Body getBody1()
        Returns the first Body.
        Returns:
        Body
      • getBody2

        public Body getBody2()
        Returns the second Body.
        Returns:
        Body
      • setOnIsland

        void setOnIsland​(boolean onIsland)
        Sets the on Island flag to the given value.
        Parameters:
        onIsland - true if the Constraint has been added to an Island
      • isOnIsland

        boolean isOnIsland()
        Returns true if this Constraint has been added to an Island
        Returns:
        boolean