jfreerails.world.train
Class CompositeSpeedAgainstTime

java.lang.Object
  extended by jfreerails.world.train.CompositeSpeedAgainstTime
All Implemented Interfaces:
java.io.Serializable, Activity<SpeedTimeAndStatus>, FreerailsSerializable, SpeedAgainstTime

public class CompositeSpeedAgainstTime
extends java.lang.Object
implements Activity<SpeedTimeAndStatus>, SpeedAgainstTime

See Also:
Serialized Form

Nested Class Summary
private static class CompositeSpeedAgainstTime.TandI
          Used to enable 2 values to be returned from the method getIndex(double t)
 
Field Summary
private  double finalS
           
private  double finalT
           
private static long serialVersionUID
           
private  ImList<SpeedAgainstTime> values
           
 
Constructor Summary
CompositeSpeedAgainstTime(SpeedAgainstTime... accs)
           
 
Method Summary
 double calcA(double t)
           
 double calcS(double t)
          Returns the distance travelled at time t.
 double calcT(double s)
          Returns the time taken to travel distance s.
 double calcV(double t)
           
(package private)  void checkT(double t)
           
 double duration()
           
 boolean equals(java.lang.Object o)
           
private  CompositeSpeedAgainstTime.TandI getIndex(double t)
           
 double getS()
           
 SpeedTimeAndStatus getState(double dt)
           
 double getT()
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

values

private final ImList<SpeedAgainstTime> values

finalT

private final double finalT

finalS

private final double finalS
Constructor Detail

CompositeSpeedAgainstTime

public CompositeSpeedAgainstTime(SpeedAgainstTime... accs)
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

duration

public double duration()
Specified by:
duration in interface Activity<SpeedTimeAndStatus>

getState

public SpeedTimeAndStatus getState(double dt)
Specified by:
getState in interface Activity<SpeedTimeAndStatus>

calcS

public double calcS(double t)
Description copied from interface: SpeedAgainstTime
Returns the distance travelled at time t. The returned value, s, satisfies the following conditions:
  1. s >= 0
  2. s <= getS()
  3. s = 0 if t = 0
  4. s = getS() if t = getT()

Specified by:
calcS in interface SpeedAgainstTime
Returns:
s

calcT

public double calcT(double s)
Description copied from interface: SpeedAgainstTime
Returns the time taken to travel distance s. The returned value, t, satisfies the following conditions:
  1. t >= 0
  2. t <= getT()
  3. t = 0 if s = 0
  4. t = getT() if s = getS()

Specified by:
calcT in interface SpeedAgainstTime
Returns:
t

calcV

public double calcV(double t)
Specified by:
calcV in interface SpeedAgainstTime

calcA

public double calcA(double t)
Specified by:
calcA in interface SpeedAgainstTime

getT

public double getT()
Specified by:
getT in interface SpeedAgainstTime
Returns:
The time taken to travel the distance given by getS().

getS

public double getS()
Specified by:
getS in interface SpeedAgainstTime
Returns:
The distance traveled during at time given by getT().

getIndex

private CompositeSpeedAgainstTime.TandI getIndex(double t)

checkT

void checkT(double t)