Module org.dyn4j

Class FrictionJoint<T extends PhysicsBody>

  • Type Parameters:
    T - the PhysicsBody type
    All Implemented Interfaces:
    DataContainer, Shiftable, Ownable

    public class FrictionJoint<T extends PhysicsBody>
    extends Joint<T>
    implements Shiftable, DataContainer
    Implementation of a friction joint.

    A friction joint is a constraint that drives both linear and angular velocities to zero.

    This joint is typically used with one dynamic and one static body. In this context, the joint will apply linear and angular friction to stop the body's motion.

    Setting the maximum force and torque values will determine the rate at which the motion is stopped. These values are defaulted to 10 and 0.25 respectively.

    NOTE: In versions 3.4.0 and below, the maximum force and torque values were 0 by default. This was changed in 4.0.0 to allow users to better understand the use of this joint when first using it.

    Since:
    1.0.0
    Version:
    4.0.0
    Author:
    William Bittle
    See Also:
    Documentation
    • Method Detail

      • initializeConstraints

        public void initializeConstraints​(TimeStep step,
                                          Settings settings)
        Description copied from class: Joint
        Performs any initialization of the velocity and position constraints.
        Specified by:
        initializeConstraints in class Joint<T extends PhysicsBody>
        Parameters:
        step - the time step information
        settings - the current world settings
      • solveVelocityConstraints

        public void solveVelocityConstraints​(TimeStep step,
                                             Settings settings)
        Description copied from class: Joint
        Solves the velocity constraints.
        Specified by:
        solveVelocityConstraints in class Joint<T extends PhysicsBody>
        Parameters:
        step - the time step information
        settings - the current world settings
      • solvePositionConstraints

        public boolean solvePositionConstraints​(TimeStep step,
                                                Settings settings)
        Description copied from class: Joint
        Solves the position constraints.
        Specified by:
        solvePositionConstraints in class Joint<T extends PhysicsBody>
        Parameters:
        step - the time step information
        settings - the current world settings
        Returns:
        boolean true if the position constraints were solved
      • getReactionForce

        public Vector2 getReactionForce​(double invdt)
        Description copied from class: Joint
        Returns the force applied to the PhysicsBodys in order to satisfy the constraint in newtons.
        Specified by:
        getReactionForce in class Joint<T extends PhysicsBody>
        Parameters:
        invdt - the inverse delta time
        Returns:
        Vector2
      • getReactionTorque

        public double getReactionTorque​(double invdt)
        Description copied from class: Joint
        Returns the torque applied to the PhysicsBodys in order to satisfy the constraint in newton-meters.
        Specified by:
        getReactionTorque in class Joint<T extends PhysicsBody>
        Parameters:
        invdt - the inverse delta time
        Returns:
        double
      • shift

        public void shift​(Vector2 shift)
        Description copied from interface: Shiftable
        Translates the object to match the given coordinate shift.
        Specified by:
        shift in interface Shiftable
        Parameters:
        shift - the amount to shift along the x and y axes
      • getMaximumTorque

        public double getMaximumTorque()
        Returns the maximum torque this constraint will apply in newton-meters.
        Returns:
        double
      • setMaximumTorque

        public void setMaximumTorque​(double maximumTorque)
        Sets the maximum torque this constraint will apply in newton-meters.
        Parameters:
        maximumTorque - the maximum torque in newton-meters; in the range [0, ∞]
        Throws:
        IllegalArgumentException - if maxTorque is less than zero
      • getMaximumForce

        public double getMaximumForce()
        Returns the maximum force this constraint will apply in newtons.
        Returns:
        double
      • setMaximumForce

        public void setMaximumForce​(double maximumForce)
        Sets the maximum force this constraint will apply in newtons.
        Parameters:
        maximumForce - the maximum force in newtons; in the range [0, ∞]
        Throws:
        IllegalArgumentException - if maxForce is less than zero