faa.tg.ground
Class GroundFixConnection

java.lang.Object
  extended by faa.tg.ground.GroundFixConnection
All Implemented Interfaces:
TextWritable, Filterable, ParameterizedCurve, Recordable, ManagedObject, java.io.Serializable

public class GroundFixConnection
extends java.lang.Object
implements TextWritable, ParameterizedCurve, ManagedObject

A GroundFixConnection is one-way. It's possible to do a two- way connection, but this allows us more flexibility in applying penalties. For example, going from A -> B could have a certain cost, but B -> A could cost more (i.e., it is frowned upon). A possible downside (or upside, depending on how you view it) is that this class only cares about the destination. Thus, multiple nodes could use this connection to connect to a single destination node. Another possible use is making one-way paths. For connections where the cost is determined by the constructor, the value is equal to the distance of the path in feet.

Version:
$Id: GroundFixConnection.java,v 3.67 2009/01/14 00:26:11 lykensj Exp $
Author:
James Hamilton
See Also:
Serialized Form

Field Summary
private  double a0
           
private  double a1
           
private  double a1Xa1
           
private  double a1Xa2
           
private  double a2
           
private  double a2_2
           
private  double a3
           
private  double a3_3
           
private  double a3_6
           
private  double angleDiff
           
private  double b0
           
private  double b1
           
private  double b1Xb1
           
private  double b1Xb2
           
private  double b2
           
private  double b2_2
           
private  double b3
           
private  double b3_3
           
private  double b3_6
           
private  double coeff3
           
private  double coeff4
           
private  double coeff5
           
private  Position control1
           
private  Position control2
           
private static double CURVATURE_CONST
           
static java.lang.String CVS_VERSION_ID
          The CVS Version ID.
private  Point end
           
private  TurnDirection endDirection
           
private  GroundFixState endState
           
private static int MAX_GENERATION
           
private  double mCost
           
private  boolean mCurved
           
private  GroundFix mDest
           
private  TrueHeading mEndHeading
           
private  Distance mLength
           
private  GroundFix mOrig
           
private  TrueHeading mStartHeading
           
private static double newtonCotes8DivisorA
           
private static double newtonCotes8DivisorB
           
private  PolygonalPath path
           
(package private) static long serialVersionUID
           
private  Point start
           
private  GroundFixState startState
           
 
Constructor Summary
protected GroundFixConnection(GroundFix aFirst, GroundFix aSecond, Locale locale)
          Constructs a GroundFixConnection with aSecond as the destination and the cost of traversing the segment as the distance between the two GroundFixs.
protected GroundFixConnection(GroundFix origin, GroundFix destination, Position control1, Position control2, Locale locale)
          Construct a GroundFixConnection with aSecond as the destination.
 
Method Summary
protected  double arcAngularChange()
           
private  double arcLength(double aInitialT, double aFinalT)
          Uses Newton-Cotes to approximate the integral
private  double calcAngleDiff(double t)
           
 double calcArcDiffEval(double t)
           
private  double calculateArcIntegral(double aInitialT, double aFinalT)
           
 Distance calculateArcLength(double aInitialT, double aFinalT)
           
 double calculateCurvature(double t)
           
 Distance calculateRemainingArcLength(double aT)
           
 boolean endDirectionCompatibleWith(TurnDirection dir)
           
(package private)  boolean endsSimilarly(GroundFixConnection gfc)
           
 Coordinate findClosestCoordinate(Point p)
          Finds the closest Coordinate on the curve to the argument.
 Point findClosestPoint(Point p)
           
protected  double findClosestValue(double NX, double NY)
          Will find the closest point to the connection(Bezier curve) (more numerically stable than the TVal version)
 double findClosestValue(Point p)
          Will find the closest point to the connection(Bezier curve) (more numerically stable than the TVal version)
 double findDistSq(double NX, double NY, double Tval)
          Finds the distance squared of the point (NX,NY) to the point on the curve at the parametric value Tval
 GroundFixState findEndState()
           
 double findHighestCurvatureLocation()
          Uses Sturm's method to solve a polynomial to find the (a) parametric value of largest curvature in [0,1]
 java.util.Set<java.lang.Double> findIntersections(LineSegment seg, double start)
          Takes a LineSegment and returns the first intersection found as a parametric value.
protected  double findLineIntersection(double A1, double A0, double B1, double B0)
          Takes a line in the parametric form Y = B1 * t + B0 and X = A1 * t + A0 and returns the first intersection found as a parametric value.
 GroundFixState findStartState()
           
 PolygonalPath generatePolygonalPath(double t)
          Generates a PolygonalPath starting at the parametric argument.
 PolygonalPath generatePolygonalPath(double t, double t2)
          Generates a PolygonalPath in the parametric range [t,t2] on the connection.
 Position getControl1()
           
 Position getControl2()
           
 Coordinate getCoordinate(double t)
          This method can return a Coordinate for a specific t-value on the Bezier spline defined by this connection.
 double getCost()
          Gets the cost associated with traversing this GroundFixConnection
 GroundFix getDestination()
          Gets the GroundFix that is the destination of this segment
 TrueHeading getEndHeading()
          Returns the heading at the end of the connection
 Point getEndingPoint()
           
 Distance getLength()
          Returns the length of this connection.
 java.lang.String getName()
          Represents a unique instance of a class: objects should either be the only object of a class with that name, or should replace obsolete objects of that name.
 GroundFix getOrigin()
          Gets the GroundFix that is the origin of this connection
 Point getPoint(double t)
          This method can return a Point2D for a specific t-value on the Bezier spline defined by this connection.
 PolygonalPath getPolygonalPath()
           
 GroundFixConnection getReciprocal()
          Returns the reciprocal connection of this one, if it exists.
 TrueHeading getStartHeading()
          Returns the heading at the start of the connection.
 Point getStartingPoint()
           
 boolean hasReciprocal()
          Returns whether this connection has a reciprocal connection.
private static double intPow(double a, int b)
          returns a^b power where b is an int in the range [1,3]
 boolean isCurved()
          Returns whether the segment is curved.
 boolean isCurved(double t)
           
 double maximum()
           
 double minimum()
           
 double projectAhead(Distance aDist, double aT)
          Returns the parametric value on the curve that is aDist forward from aT.
 Point projectionFromStart(Distance aDist)
          Returns the point whose path distance is the aDist from the origin.
protected  void setEndState(GroundFixState gfs)
          Sets the end state to the input.
protected  void setStartState(GroundFixState gfs)
          Sets the start state to the input.
private  int solutionFinder(SturmNode father, java.util.ArrayList<java.lang.Double> solvec, java.util.ArrayList<SturmPoly> remainders, SturmPoly derivDist)
           
 java.lang.String toDraText()
          Returns text for drat Required by TextWritable interface
 java.lang.String toString()
          Returns a String representation of the object
private  java.util.ArrayList<Point> tracePolyPoints(double startVal, double endVal, double degrees)
          Finds the sequence points of this GroundFixConnection in the range [startVal,endVal] such that for a sequence S of size n, for all a_i, i not n, in S, |phi(a_i) - phi(a_i+1)| = degree, where phi(p) is the heading of the groundFixConnection at the parametric value p, and a_1 = startVal and a_n = endVal.
 boolean validateParameter(double t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

CVS_VERSION_ID

public static final java.lang.String CVS_VERSION_ID
The CVS Version ID.

See Also:
Constant Field Values

CURVATURE_CONST

private static final double CURVATURE_CONST
See Also:
Constant Field Values

mOrig

private final GroundFix mOrig

mDest

private final GroundFix mDest

control1

private final Position control1

control2

private final Position control2

mCost

private final double mCost

mLength

private final Distance mLength

mCurved

private final boolean mCurved

a1

private final double a1

a2

private final double a2

a3

private final double a3

b1

private final double b1

b2

private final double b2

b3

private final double b3

a0

private final double a0

b0

private final double b0

coeff3

private final double coeff3

coeff4

private final double coeff4

coeff5

private final double coeff5

a2_2

private final double a2_2

b2_2

private final double b2_2

a3_3

private final double a3_3

b3_3

private final double b3_3

b3_6

private final double b3_6

a3_6

private final double a3_6

a1Xa2

private final double a1Xa2

b1Xb2

private final double b1Xb2

b1Xb1

private final double b1Xb1

a1Xa1

private final double a1Xa1

mStartHeading

private final TrueHeading mStartHeading

mEndHeading

private final TrueHeading mEndHeading

path

private final transient PolygonalPath path

start

private final transient Point start

end

private final transient Point end

angleDiff

private final double angleDiff

endDirection

private final transient TurnDirection endDirection

newtonCotes8DivisorA

private static final double newtonCotes8DivisorA
See Also:
Constant Field Values

newtonCotes8DivisorB

private static final double newtonCotes8DivisorB
See Also:
Constant Field Values

MAX_GENERATION

private static final int MAX_GENERATION
See Also:
Constant Field Values

startState

private transient GroundFixState startState

endState

private transient GroundFixState endState
Constructor Detail

GroundFixConnection

protected GroundFixConnection(GroundFix aFirst,
                              GroundFix aSecond,
                              Locale locale)
Constructs a GroundFixConnection with aSecond as the destination and the cost of traversing the segment as the distance between the two GroundFixs. We should not be using this constructor but I left it in from when I was testing that the path-finding worked correctly when you using runtime calculated distances.

Parameters:
aFirst - the origin
aSecond - the destination

GroundFixConnection

protected GroundFixConnection(GroundFix origin,
                              GroundFix destination,
                              Position control1,
                              Position control2,
                              Locale locale)
Construct a GroundFixConnection with aSecond as the destination. The cost of the node is computed by calculating the distance covered by the Bezier curve drawn using the two control point positions and the two GroundFixs. They are used in the order: aFirst, aCtlOne, aCtlTwo, aSecond.

Parameters:
origin - the origin
destination - the destination
control1 - the first control point
control2 - the second control point
Method Detail

getName

public java.lang.String getName()
Description copied from interface: ManagedObject
Represents a unique instance of a class: objects should either be the only object of a class with that name, or should replace obsolete objects of that name.

Specified by:
getName in interface ManagedObject
Returns:
Returns the name of the object.

getCost

public double getCost()
Gets the cost associated with traversing this GroundFixConnection

Returns:
the cost associated with this segment

getLength

public Distance getLength()
Returns the length of this connection. Please note that this is different from the segment's cost.

Specified by:
getLength in interface ParameterizedCurve
Returns:
the Distance of this connection

getOrigin

public GroundFix getOrigin()
Gets the GroundFix that is the origin of this connection

Returns:
the origin of this connection

getDestination

public GroundFix getDestination()
Gets the GroundFix that is the destination of this segment

Returns:
the destination of this connection

getControl1

public Position getControl1()

getControl2

public Position getControl2()

isCurved

public boolean isCurved()
Returns whether the segment is curved. This is false unless the connection is created using control points, in which case it is determined at the end of the calculateCurveLength method below.

Returns:
whether the connection is curved or not

isCurved

public boolean isCurved(double t)

calculateCurvature

public double calculateCurvature(double t)

toString

public java.lang.String toString()
Returns a String representation of the object

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the object

toDraText

public java.lang.String toDraText()
Returns text for drat Required by TextWritable interface

Specified by:
toDraText in interface TextWritable
Returns:
Returns a DR&A format text output string.

arcAngularChange

protected double arcAngularChange()

findHighestCurvatureLocation

public double findHighestCurvatureLocation()
Uses Sturm's method to solve a polynomial to find the (a) parametric value of largest curvature in [0,1]

Returns:
the parametric location as a double

getCoordinate

public Coordinate getCoordinate(double t)
This method can return a Coordinate for a specific t-value on the Bezier spline defined by this connection.

Parameters:
t - the t-value, must be between zero and one
Returns:
the Coordinate for the t-value

getPoint

public Point getPoint(double t)
This method can return a Point2D for a specific t-value on the Bezier spline defined by this connection.

Specified by:
getPoint in interface ParameterizedCurve
Parameters:
t - the t-value, must be between zero and one
Returns:
the Point2D for the t-value

getStartHeading

public TrueHeading getStartHeading()
Returns the heading at the start of the connection.

Returns:
the heading at the start of the connection

getEndHeading

public TrueHeading getEndHeading()
Returns the heading at the end of the connection

Returns:
the heading at the end of the connection

hasReciprocal

public boolean hasReciprocal()
Returns whether this connection has a reciprocal connection. For example, if this connection represents A->B, B->A would be the reciprocal.

Returns:
whether this connection has a reciprocal

getReciprocal

public GroundFixConnection getReciprocal()
Returns the reciprocal connection of this one, if it exists. It is possible for this method to return null.


calculateArcLength

public Distance calculateArcLength(double aInitialT,
                                   double aFinalT)
Specified by:
calculateArcLength in interface ParameterizedCurve

arcLength

private double arcLength(double aInitialT,
                         double aFinalT)
Uses Newton-Cotes to approximate the integral


calculateArcIntegral

private double calculateArcIntegral(double aInitialT,
                                    double aFinalT)

calcAngleDiff

private double calcAngleDiff(double t)

calculateRemainingArcLength

public Distance calculateRemainingArcLength(double aT)
Specified by:
calculateRemainingArcLength in interface ParameterizedCurve

calcArcDiffEval

public final double calcArcDiffEval(double t)

findClosestValue

public double findClosestValue(Point p)
Will find the closest point to the connection(Bezier curve) (more numerically stable than the TVal version)

Specified by:
findClosestValue in interface ParameterizedCurve
Parameters:
p - the point to find the nearest point of on the curve.
Returns:
a TVal.

findClosestPoint

public Point findClosestPoint(Point p)
Specified by:
findClosestPoint in interface ParameterizedCurve

findClosestValue

protected double findClosestValue(double NX,
                                  double NY)
Will find the closest point to the connection(Bezier curve) (more numerically stable than the TVal version)

Parameters:
NX - x coord in meters from point defined for this.proj
NY - y coord in meters from point defined for this.proj
Returns:
a TVal.

findDistSq

public double findDistSq(double NX,
                         double NY,
                         double Tval)
Finds the distance squared of the point (NX,NY) to the point on the curve at the parametric value Tval

Parameters:
NX - the X value
NY - the Y value
Tval - the parametric location of the other point.
Returns:
the distance between the points, squared.

solutionFinder

private int solutionFinder(SturmNode father,
                           java.util.ArrayList<java.lang.Double> solvec,
                           java.util.ArrayList<SturmPoly> remainders,
                           SturmPoly derivDist)

projectAhead

public double projectAhead(Distance aDist,
                           double aT)
Returns the parametric value on the curve that is aDist forward from aT. This value may be greater than 1, in which case the point is not on the Bezier curve.

Specified by:
projectAhead in interface ParameterizedCurve
Parameters:
Distance - aDist the distance forward to examine
double - aT the starting parametric value

projectionFromStart

public Point projectionFromStart(Distance aDist)
Returns the point whose path distance is the aDist from the origin. The result may be beyond the Bezier curve.

Parameters:
aDist -
Returns:
a Point representing the solution.

intPow

private static double intPow(double a,
                             int b)
returns a^b power where b is an int in the range [1,3]

Returns:
a^b power where b is an int

findLineIntersection

protected double findLineIntersection(double A1,
                                      double A0,
                                      double B1,
                                      double B0)
Takes a line in the parametric form Y = B1 * t + B0 and X = A1 * t + A0 and returns the first intersection found as a parametric value. Behaviour is indeterminate if there is no intersection.

Parameters:
A1 - the x-slope
A0 - the x-offset
B1 - the y-slope
B0 - the y-offset
Returns:
the parametric value of an intersection.

findIntersections

public java.util.Set<java.lang.Double> findIntersections(LineSegment seg,
                                                         double start)
Takes a LineSegment and returns the first intersection found as a parametric value. Behaviour is indeterminate if there is no intersection.

Specified by:
findIntersections in interface ParameterizedCurve
Parameters:
seg - the line segment to test.
Returns:
the parametric value of an intersection.

tracePolyPoints

private java.util.ArrayList<Point> tracePolyPoints(double startVal,
                                                   double endVal,
                                                   double degrees)
Finds the sequence points of this GroundFixConnection in the range [startVal,endVal] such that for a sequence S of size n, for all a_i, i not n, in S, |phi(a_i) - phi(a_i+1)| = degree, where phi(p) is the heading of the groundFixConnection at the parametric value p, and a_1 = startVal and a_n = endVal.

Parameters:
startVal - parametric starting value
endVal - parametric ending value
degrees - is chosen angular difference
Returns:
an ArrayList containing the sought points in order.

generatePolygonalPath

public PolygonalPath generatePolygonalPath(double t)
Generates a PolygonalPath starting at the parametric argument. If t < 0 or t > 1 the PolygonalPath will extend beyond this ground fix connection. If t > 1 the direction will be reversed.

Parameters:
t - parametric value of the starting point.
Returns:
a Polygonal path starting from t to the destination.

generatePolygonalPath

public PolygonalPath generatePolygonalPath(double t,
                                           double t2)
Generates a PolygonalPath in the parametric range [t,t2] on the connection. If [t,t2] is not within [0,1], the result will extend beyond the connection.

Parameters:
t - starting parametric value.
t2 - ending parametric value.
Returns:
a PolygonalPath from t to t2.

findClosestCoordinate

public Coordinate findClosestCoordinate(Point p)
Finds the closest Coordinate on the curve to the argument.

Parameters:
p - the point to check.
Returns:
the closest Coordinate

getPolygonalPath

public PolygonalPath getPolygonalPath()
Specified by:
getPolygonalPath in interface ParameterizedCurve
Returns:
the stored PolygonalPath for the totality of the connection.

getStartingPoint

public Point getStartingPoint()
Specified by:
getStartingPoint in interface ParameterizedCurve
Returns:
the origin as a Point.

getEndingPoint

public Point getEndingPoint()
Specified by:
getEndingPoint in interface ParameterizedCurve
Returns:
the destination as a Point.

findEndState

public GroundFixState findEndState()

findStartState

public GroundFixState findStartState()

setStartState

protected void setStartState(GroundFixState gfs)
Sets the start state to the input. If it is not valid, a TgMsg is written to the console.

Parameters:
gfs - the new start state.

setEndState

protected void setEndState(GroundFixState gfs)
Sets the end state to the input. If it is not valid, a TgMsg is written to the console.

Parameters:
gfs - the new end state.

endDirectionCompatibleWith

public boolean endDirectionCompatibleWith(TurnDirection dir)
Parameters:
dir - the direction to check
Returns:
if the end direction given is compatible with this ground fix connection.

endsSimilarly

boolean endsSimilarly(GroundFixConnection gfc)

maximum

public double maximum()
Specified by:
maximum in interface ParameterizedCurve

minimum

public double minimum()
Specified by:
minimum in interface ParameterizedCurve

validateParameter

public boolean validateParameter(double t)
Specified by:
validateParameter in interface ParameterizedCurve