Module org.dyn4j

Class Joint

    • Field Detail

      • id

        protected final java.util.UUID id
        The joint's unique identifier
      • collisionAllowed

        protected boolean collisionAllowed
        Whether the pair of bodies joined together can collide with each other
      • userData

        protected java.lang.Object userData
        The user data
    • Constructor Detail

      • Joint

        public Joint​(Body body1,
                     Body body2)
        Optional constructor.

        Assumes that the joined bodies do not participate in collision detection and resolution.

        Parameters:
        body1 - the first Body
        body2 - the second Body
        Throws:
        java.lang.NullPointerException - if body1 or body2 is null
      • Joint

        public Joint​(Body body1,
                     Body body2,
                     boolean collisionAllowed)
        Full constructor.
        Parameters:
        body1 - the first Body
        body2 - the second Body
        collisionAllowed - true if the joined Bodys can take part in collision detection
        Throws:
        java.lang.NullPointerException - if body1 or body2 is null
    • Method Detail

      • initializeConstraints

        public abstract void initializeConstraints​(Step step,
                                                   Settings settings)
        Performs any initialization of the velocity and position constraints.
        Parameters:
        step - the time step information
        settings - the current world settings
      • solveVelocityConstraints

        public abstract void solveVelocityConstraints​(Step step,
                                                      Settings settings)
        Solves the velocity constraints.
        Parameters:
        step - the time step information
        settings - the current world settings
      • solvePositionConstraints

        public abstract boolean solvePositionConstraints​(Step step,
                                                         Settings settings)
        Solves the position constraints.
        Parameters:
        step - the time step information
        settings - the current world settings
        Returns:
        boolean true if the position constraints were solved
      • getAnchor1

        public abstract Vector2 getAnchor1()
        Returns the anchor point on the first Body in world coordinates.
        Returns:
        Vector2
      • getAnchor2

        public abstract Vector2 getAnchor2()
        Returns the anchor point on the second Body in world coordinates.
        Returns:
        Vector2
      • getReactionForce

        public abstract Vector2 getReactionForce​(double invdt)
        Returns the force applied to the Bodys in order to satisfy the constraint in newtons.
        Parameters:
        invdt - the inverse delta time
        Returns:
        Vector2
      • getReactionTorque

        public abstract double getReactionTorque​(double invdt)
        Returns the torque applied to the Bodys in order to satisfy the constraint in newton-meters.
        Parameters:
        invdt - the inverse delta time
        Returns:
        double
      • getId

        @Deprecated
        public java.util.UUID getId()
        Deprecated.
        ID schemes should be implemented by the user where needed; since 3.4.0
        Returns the unique identifier for this joint instance.
        Returns:
        String
        Since:
        3.0.1
      • isActive

        public boolean isActive()
        Returns true if this Joint is active.

        A joint is only active if both joined Bodys are active.

        Returns:
        boolean
      • isCollisionAllowed

        public boolean isCollisionAllowed()
        Returns true if collision between the joined Bodys is allowed.
        Returns:
        boolean
      • setCollisionAllowed

        public void setCollisionAllowed​(boolean flag)
        Sets whether collision is allowed between the joined Bodys.
        Parameters:
        flag - true if collisions are allowed
      • getUserData

        public java.lang.Object getUserData()
        Description copied from interface: DataContainer
        Gets the custom user data.
        Specified by:
        getUserData in interface DataContainer
        Returns:
        Object will return null if not set
      • setUserData

        public void setUserData​(java.lang.Object userData)
        Description copied from interface: DataContainer
        Sets the custom user data to the given data.
        Specified by:
        setUserData in interface DataContainer
        Parameters:
        userData - the user data