Module org.dyn4j

Class Joint<T extends PhysicsBody>

    • Constructor Detail

      • Joint

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

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

        Parameters:
        body1 - the first PhysicsBody
        body2 - the second PhysicsBody
        Throws:
        NullPointerException - if body1 or body2 is null
      • Joint

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

      • initializeConstraints

        public abstract void initializeConstraints​(TimeStep 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​(TimeStep step,
                                                      Settings settings)
        Solves the velocity constraints.
        Parameters:
        step - the time step information
        settings - the current world settings
      • solvePositionConstraints

        public abstract boolean solvePositionConstraints​(TimeStep 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
      • getBody1

        public T getBody1()
        Returns the first body.
        Returns:
        T
      • getBody2

        public T getBody2()
        Returns the second body.
        Returns:
        T
      • getOtherBody

        public T getOtherBody​(CollisionBody<?> body)
        Returns the body that does not match the given body.

        If the given body is neither body1 or body2, null is returned.

        Parameters:
        body - the body
        Returns:
        T
      • getAnchor1

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

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

        public abstract Vector2 getReactionForce​(double invdt)
        Returns the force applied to the PhysicsBodys 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 PhysicsBodys in order to satisfy the constraint in newton-meters.
        Parameters:
        invdt - the inverse delta time
        Returns:
        double
      • isActive

        @Deprecated
        public boolean isActive()
        Deprecated.
        Deprecated in 4.0.0. Use the isEnabled method instead
        Returns true if this Joint is active.

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

        Returns:
        boolean
      • isEnabled

        public boolean isEnabled()
        Returns true if this Joint is enabled.

        A joint is only enabled if both joined PhysicsBodys are enabled.

        Returns:
        boolean
      • isCollisionAllowed

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

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

        public 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​(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
      • isOnIsland

        @Deprecated
        public boolean isOnIsland()
        Deprecated.
        Deprecated in 4.0.0. No replacement needed.
        Returns true if this joint is on an island.
        Returns:
        boolean
      • setOnIsland

        @Deprecated
        public void setOnIsland​(boolean flag)
        Deprecated.
        Deprecated in 4.0.0. No replacement needed.
        Flags this joint as being on an island.
        Parameters:
        flag - true if this joint is on an island
      • getOwner

        public Object getOwner()
        Description copied from interface: Ownable
        Returns the owner for this body.
        Specified by:
        getOwner in interface Ownable
        Returns:
        Object
      • setOwner

        public void setOwner​(Object owner)
        Description copied from interface: Ownable
        Sets the owner of this body.
        Specified by:
        setOwner in interface Ownable
        Parameters:
        owner - the owner