jrobots.utils
Class LinearPredictor

java.lang.Object
  extended by jrobots.utils.LinearPredictor
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class LinearPredictor
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

The LinearPredictor is a helper class suited for linear extrapolation. It works with Scan values.

See Also:
predict(Scan, Scan, double), constructScan(Vector, double), Serialized Form

Constructor Summary
protected LinearPredictor()
          Do not instantiate
 
Method Summary
static Scan constructScan(Vector targetPosition, double timeOfScan)
          Constructs an artificial scan value for use in the LinearPredictor.
static Vector predict(Scan scan1, Scan scan2, double time)
          This method can be used to extrapolate the enemy's movement linearly.
static Vector predict(SonarTrace trace1, SonarTrace trace2, double time)
          This method can be used to extrapolate the enemy's movement linearly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearPredictor

protected LinearPredictor()
Do not instantiate

Method Detail

constructScan

public static Scan constructScan(Vector targetPosition,
                                 double timeOfScan)
Constructs an artificial scan value for use in the LinearPredictor.

You can use the returned values from the radar scanner directly in predict. Use this routine if you know exact positions you want to extrapolate from.

Parameters:
targetPosition - - approximated target position
timeOfScan - - time at which the target was at the given position
Returns:

predict

public static Vector predict(Scan scan1,
                             Scan scan2,
                             double time)
This method can be used to extrapolate the enemy's movement linearly.

The parameters scan1 and scan2 provide the two necessary vectors. They contain a position (at least approximately) and a timestamp.
The third parameter specifies the target time of extrapolation (since begin of the encounter).

Parameters:
scan1 - a Scan which sighted the enemy (the order of scans is not relevant)
scan2 - a Scan which sighted the same enemy (the order of scans is not relevant)
time - Where will the enemy be at that time? [s] (Time since the beginning of the match)
Returns:
extrapolated position at given time

predict

public static Vector predict(SonarTrace trace1,
                             SonarTrace trace2,
                             double time)
This method can be used to extrapolate the enemy's movement linearly.

The parameters scan1 and scan2 provide the two necessary vectors. They contain a position (at least approximately) and a timestamp.
The third parameter specifies the target time of extrapolation (since begin of the encounter).

Parameters:
trace1 - a Scan which sighted the enemy (the order of scans is not relevant)
trace2 - a Scan which sighted the same enemy (the order of scans is not relevant)
time - Where will the enemy be at that absolute time? [s] (Time since the beginning of the match)
Returns:
extrapolated absolute position at given time