Module org.dyn4j

Class Step


  • public class Step
    extends java.lang.Object
    Class encapsulating the timestep information.

    The World class maintains an instance of this class to perform various functions.

    A time step represents the elapsed time since the last update.

    Since:
    1.0.0
    Version:
    3.2.0
    Author:
    William Bittle
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double dt
      The elapsed time
      protected double dt0
      The last elapsed time
      protected double dtRatio
      The elapsed time ratio from the last to the current
      protected double invdt
      The inverse elapsed time
      protected double invdt0
      The last inverse elapsed time
    • Constructor Summary

      Constructors 
      Constructor Description
      Step​(double dt)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getDeltaTime()
      Returns the elapsed time since the last time step in seconds.
      double getDeltaTimeRatio()
      Returns the ratio of the last elapsed time to the current elapsed time.
      double getInverseDeltaTime()
      Returns the inverse of the elapsed time (in seconds) since the last time step.
      double getPreviousInverseDeltaTime()
      Returns the previous frame's inverse elapsed time (in seconds).
      double getPrevousDeltaTime()
      Returns the previous frame's elapsed time in seconds.
      java.lang.String toString()  
      protected void update​(double dt)
      Updates the current Step using the new elapsed time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • dt0

        protected double dt0
        The last elapsed time
      • invdt0

        protected double invdt0
        The last inverse elapsed time
      • dt

        protected double dt
        The elapsed time
      • invdt

        protected double invdt
        The inverse elapsed time
      • dtRatio

        protected double dtRatio
        The elapsed time ratio from the last to the current
    • Constructor Detail

      • Step

        public Step​(double dt)
        Default constructor.
        Parameters:
        dt - the initial delta time; in seconds-1
    • Method Detail

      • toString

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

        protected void update​(double dt)
        Updates the current Step using the new elapsed time.
        Parameters:
        dt - in seconds.
      • getDeltaTime

        public double getDeltaTime()
        Returns the elapsed time since the last time step in seconds.
        Returns:
        double
      • getInverseDeltaTime

        public double getInverseDeltaTime()
        Returns the inverse of the elapsed time (in seconds) since the last time step.
        Returns:
        double
      • getDeltaTimeRatio

        public double getDeltaTimeRatio()
        Returns the ratio of the last elapsed time to the current elapsed time.

        This is used to cope with a variable time step.

        Returns:
        double
      • getPrevousDeltaTime

        public double getPrevousDeltaTime()
        Returns the previous frame's elapsed time in seconds.
        Returns:
        double
      • getPreviousInverseDeltaTime

        public double getPreviousInverseDeltaTime()
        Returns the previous frame's inverse elapsed time (in seconds).
        Returns:
        double