- Object
-
- TimeStep
-
public class TimeStep extends Object
Class encapsulating the timestep information.A time step represents the elapsed time since the last update.
- Since:
- 1.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description protected double
dt
The elapsed timeprotected double
dt0
The last elapsed timeprotected double
dtRatio
The elapsed time ratio from the last to the currentprotected double
invdt
The inverse elapsed timeprotected double
invdt0
The last inverse elapsed time
-
Constructor Summary
Constructors Constructor Description TimeStep(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.String
toString()
void
update(double dt)
Updates the currentTimeStep
using the new elapsed time.
-
-
-
Constructor Detail
-
TimeStep
public TimeStep(double dt)
Default constructor.- Parameters:
dt
- the initial delta time in seconds; must be greater than zero- Throws:
IllegalArgumentException
- if dt is less than or equal to zero
-
-
Method Detail
-
update
public void update(double dt)
Updates the currentTimeStep
using the new elapsed time.- Parameters:
dt
- in delta time in seconds; must be greater than zero- Throws:
IllegalArgumentException
- if dt is less than or equal to zero
-
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
-
-