Module org.dyn4j

Class Settings


  • public class Settings
    extends java.lang.Object
    Responsible for housing all of the dynamics engine's settings.
    Since:
    1.0.0
    Version:
    3.1.1
    Author:
    William Bittle
    • Field Detail

      • DEFAULT_STEP_FREQUENCY

        public static final double DEFAULT_STEP_FREQUENCY
        The default step frequency of the dynamics engine; in seconds
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_TRANSLATION

        public static final double DEFAULT_MAXIMUM_TRANSLATION
        The default maximum translation a Body can have in one time step; in meters
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_ROTATION

        public static final double DEFAULT_MAXIMUM_ROTATION
        The default maximum rotation a Body can have in one time step; in radians
        See Also:
        Constant Field Values
      • DEFAULT_SLEEP_LINEAR_VELOCITY

        public static final double DEFAULT_SLEEP_LINEAR_VELOCITY
        The default maximum velocity for a Body to go to sleep; in meters/second
        See Also:
        Constant Field Values
      • DEFAULT_SLEEP_ANGULAR_VELOCITY

        public static final double DEFAULT_SLEEP_ANGULAR_VELOCITY
        The default maximum angular velocity for a Body to go to sleep; in radians/second
      • DEFAULT_SLEEP_TIME

        public static final double DEFAULT_SLEEP_TIME
        The default required time a Body must maintain small motion so that its put to sleep; in seconds
        See Also:
        Constant Field Values
      • DEFAULT_SOLVER_ITERATIONS

        public static final int DEFAULT_SOLVER_ITERATIONS
        The default number of solver iterations
        See Also:
        Constant Field Values
      • DEFAULT_WARM_START_DISTANCE

        public static final double DEFAULT_WARM_START_DISTANCE
        The default warm starting distance; in meters2
        See Also:
        Constant Field Values
      • DEFAULT_RESTITUTION_VELOCITY

        public static final double DEFAULT_RESTITUTION_VELOCITY
        The default restitution velocity; in meters/second
        See Also:
        Constant Field Values
      • DEFAULT_LINEAR_TOLERANCE

        public static final double DEFAULT_LINEAR_TOLERANCE
        The default linear tolerance; in meters
        See Also:
        Constant Field Values
      • DEFAULT_ANGULAR_TOLERANCE

        public static final double DEFAULT_ANGULAR_TOLERANCE
        The default angular tolerance; in radians
      • DEFAULT_MAXIMUM_LINEAR_CORRECTION

        public static final double DEFAULT_MAXIMUM_LINEAR_CORRECTION
        The default maximum linear correction; in meters
        See Also:
        Constant Field Values
      • DEFAULT_MAXIMUM_ANGULAR_CORRECTION

        public static final double DEFAULT_MAXIMUM_ANGULAR_CORRECTION
        The default maximum angular correction; in radians
      • DEFAULT_BAUMGARTE

        public static final double DEFAULT_BAUMGARTE
        The default baumgarte
        See Also:
        Constant Field Values
    • Constructor Detail

      • Settings

        public Settings()
        Default constructor
    • Method Detail

      • toString

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

        public void reset()
        Resets the settings back to defaults.
      • getStepFrequency

        public double getStepFrequency()
        Returns the step frequency of the dynamics engine in seconds.

        Returns:
        double the step frequency
        See Also:
        setStepFrequency(double)
      • setStepFrequency

        public void setStepFrequency​(double stepFrequency)
        Sets the step frequency of the dynamics engine. This value determines how often to update the dynamics engine in seconds (every 1/60th of a second for example).

        Valid values are in the range (0, ∞] seconds.

        Versions before 3.1.1 would convert the stepFrequency parameter from seconds-1 to seconds (60 to 1/60 for example) automatically. This automatic conversion has been removed in versions 3.1.1 and higher. Instead pass in the value in seconds (1/60 for example).

        Parameters:
        stepFrequency - the step frequency
        Throws:
        java.lang.IllegalArgumentException - if stepFrequency is less than or equal to zero
      • getMaximumTranslation

        public double getMaximumTranslation()
        Returns the maximum translation a Body can have in one time step.
        Returns:
        double the maximum translation in meters
        See Also:
        setMaximumTranslation(double)
      • setMaximumTranslation

        public void setMaximumTranslation​(double maximumTranslation)
        Sets the maximum translation a Body can have in one time step.

        Valid values are in the range [0, ∞] meters

        Parameters:
        maximumTranslation - the maximum translation
        Throws:
        java.lang.IllegalArgumentException - if maxTranslation is less than zero
      • getMaximumRotation

        public double getMaximumRotation()
        Returns the maximum rotation a Body can have in one time step.
        Returns:
        double the maximum rotation in radians
        See Also:
        setMaximumRotation(double)
      • setMaximumRotation

        public void setMaximumRotation​(double maximumRotation)
        Sets the maximum rotation a Body can have in one time step.

        Valid values are in the range [0, ∞] radians

        Parameters:
        maximumRotation - the maximum rotation
        Throws:
        java.lang.IllegalArgumentException - if maxRotation is less than zero
      • isAutoSleepingEnabled

        public boolean isAutoSleepingEnabled()
        Returns true if the engine automatically puts Bodys to sleep.
        Returns:
        boolean
      • setAutoSleepingEnabled

        public void setAutoSleepingEnabled​(boolean flag)
        Sets whether the engine automatically puts Bodys to sleep.
        Parameters:
        flag - true if Bodys should be put to sleep automatically
      • getSleepLinearVelocity

        public double getSleepLinearVelocity()
        Returns the sleep linear velocity.
        Returns:
        double the sleep velocity.
        See Also:
        setSleepLinearVelocity(double)
      • setSleepLinearVelocity

        public void setSleepLinearVelocity​(double sleepLinearVelocity)
        Sets the sleep linear velocity.

        The sleep linear velocity is the maximum velocity a Body can have to be put to sleep.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        sleepLinearVelocity - the sleep linear velocity
        Throws:
        java.lang.IllegalArgumentException - if sleepLinearVelocity is less than zero
      • getSleepAngularVelocity

        public double getSleepAngularVelocity()
        Returns the sleep angular velocity.
        Returns:
        double the sleep angular velocity.
        See Also:
        setSleepAngularVelocity(double)
      • setSleepAngularVelocity

        public void setSleepAngularVelocity​(double sleepAngularVelocity)
        Sets the sleep angular velocity.

        The sleep angular velocity is the maximum angular velocity a Body can have to be put to sleep.

        Valid values are in the range [0, ∞] radians/second

        Parameters:
        sleepAngularVelocity - the sleep angular velocity
        Throws:
        java.lang.IllegalArgumentException - if sleepAngularVelocity is less than zero
      • getSleepTime

        public double getSleepTime()
        Returns the sleep time.
        Returns:
        double the sleep time
        See Also:
        setSleepTime(double)
      • setSleepTime

        public void setSleepTime​(double sleepTime)
        Sets the sleep time.

        The sleep time is the amount of time a body must be motionless before being put to sleep.

        Valid values are in the range [0, ∞] seconds

        Parameters:
        sleepTime - the sleep time
        Throws:
        java.lang.IllegalArgumentException - if sleepTime is less than zero
      • getVelocityConstraintSolverIterations

        public int getVelocityConstraintSolverIterations()
        Returns the number of iterations used to solve velocity constraints.
        Returns:
        int
      • setVelocityConstraintSolverIterations

        public void setVelocityConstraintSolverIterations​(int velocityConstraintSolverIterations)
        Sets the number of iterations used to solve velocity constraints.

        Increasing the number will increase accuracy but decrease performance.

        Valid values are in the range [1, ∞]

        Parameters:
        velocityConstraintSolverIterations - the number of iterations used to solve velocity constraints
        Throws:
        java.lang.IllegalArgumentException - if velocityConstraintSolverIterations is less than 5
      • getPositionConstraintSolverIterations

        public int getPositionConstraintSolverIterations()
        Returns the number of iterations used to solve position constraints.
        Returns:
        int
      • setPositionConstraintSolverIterations

        public void setPositionConstraintSolverIterations​(int positionConstraintSolverIterations)
        Sets the number of iterations used to solve position constraints.

        Increasing the number will increase accuracy but decrease performance.

        Valid values are in the range [1, ∞]

        Parameters:
        positionConstraintSolverIterations - the number of iterations used to solve position constraints
        Throws:
        java.lang.IllegalArgumentException - if positionConstraintSolverIterations is less than 5
      • getWarmStartDistance

        public double getWarmStartDistance()
        Returns the warm start distance.
        Returns:
        double the warm start distance
        See Also:
        setWarmStartDistance(double)
      • setWarmStartDistance

        public void setWarmStartDistance​(double warmStartDistance)
        Sets the warm start distance.

        The maximum distance from one point to another to consider the points to be the same. This distance is used to determine if the points can carry over another point's accumulated impulses to be used for warm starting the constraint solver.

        Valid values are in the range [0, ∞] meters

        Parameters:
        warmStartDistance - the warm start distance
        Throws:
        java.lang.IllegalArgumentException - if warmStartDistance is less than zero
      • getRestitutionVelocity

        public double getRestitutionVelocity()
        Returns the restitution velocity.
        Returns:
        double the restitution velocity
        See Also:
        setRestitutionVelocity(double)
      • setRestitutionVelocity

        public void setRestitutionVelocity​(double restitutionVelocity)
        Sets the restitution velocity.

        The relative velocity in the direction of the contact normal which determines whether to handle the collision as an inelastic or elastic collision.

        Valid values are in the range [0, ∞] meters/second

        Parameters:
        restitutionVelocity - the restitution velocity
        Throws:
        java.lang.IllegalArgumentException - if restitutionVelocity is less than zero
      • getLinearTolerance

        public double getLinearTolerance()
        Returns the linear tolerance.
        Returns:
        double the allowed penetration
        See Also:
        setLinearTolerance(double)
      • setLinearTolerance

        public void setLinearTolerance​(double linearTolerance)
        Sets the linear tolerance.

        Used to avoid jitter and facilitate stacking.

        Valid values are in the range (0, ∞] meters

        Parameters:
        linearTolerance - the linear tolerance
        Throws:
        java.lang.IllegalArgumentException - if linearTolerance is less than zero
      • getAngularTolerance

        public double getAngularTolerance()
        Returns the angular tolerance.
        Returns:
        double
        See Also:
        setAngularTolerance(double)
      • setAngularTolerance

        public void setAngularTolerance​(double angularTolerance)
        Sets the angular tolerance.

        Used to avoid jitter and facilitate stacking.

        Valid values are in the range (0, ∞] radians

        Parameters:
        angularTolerance - the angular tolerance
        Throws:
        java.lang.IllegalArgumentException - if angularTolerance is less than zero
      • getMaximumLinearCorrection

        public double getMaximumLinearCorrection()
        Returns the maximum linear correction.
        Returns:
        double the maximum linear correction
        See Also:
        setMaximumLinearCorrection(double)
      • setMaximumLinearCorrection

        public void setMaximumLinearCorrection​(double maximumLinearCorrection)
        Sets the maximum linear correction.

        The maximum linear correction used when estimating the current penetration depth during the position constraint solving step.

        This is used to avoid large corrections.

        Valid values are in the range (0, ∞] meters

        Parameters:
        maximumLinearCorrection - the maximum linear correction
        Throws:
        java.lang.IllegalArgumentException - if maxLinearCorrection is less than zero
      • getMaximumAngularCorrection

        public double getMaximumAngularCorrection()
        Returns the maximum angular correction.
        Returns:
        double
        See Also:
        setMaximumAngularCorrection(double)
      • setMaximumAngularCorrection

        public void setMaximumAngularCorrection​(double maximumAngularCorrection)
        Sets the maximum angular correction.

        This is used to prevent large angular corrections.

        Valid values are in the range [0, ∞] radians

        Parameters:
        maximumAngularCorrection - the maximum angular correction
        Throws:
        java.lang.IllegalArgumentException - if maxAngularCorrection is less than zero
      • getBaumgarte

        public double getBaumgarte()
        Returns the baumgarte factor.
        Returns:
        double baumgarte
        See Also:
        setBaumgarte(double)
      • setBaumgarte

        public void setBaumgarte​(double baumgarte)
        Sets the baumgarte factor.

        The position correction bias factor that determines the rate at which the position constraints are solved.

        Valid values are in the range [0, ∞].

        Parameters:
        baumgarte - the baumgarte factor
        Throws:
        java.lang.IllegalArgumentException - if baumgarte is less than zero
      • setContinuousDetectionMode

        public void setContinuousDetectionMode​(ContinuousDetectionMode mode)
        Sets the continuous collision detection mode.
        Parameters:
        mode - the CCD mode
        Throws:
        java.lang.NullPointerException - if mode is null
        Since:
        2.2.3