Package ca.spatial.tracks.builder
Class Curve
java.lang.Object
ca.spatial.tracks.builder.Curve
- All Implemented Interfaces:
Iterator<CurvePoint>
This class implements a linear curve. Linear curves have all points
in ascending X order and have no duplicate X values. The curve is
contained as a doubly-linked list.
A number of simple curve manipulations and calculation methods are provided.
The getY(double)
method will return a Y-value for any given X-value.
Value of X that are lower than the lowest defined point return the
Y-value from the lowest X-value. Similaryly values of X greater
than the higest defined point return the Y-value from the highest
X-value. For X-values that match a point with the same X-value the
corresponding Y-value is returned. Otherwise the method calculates
a linear interpolation between the two surronding points.
Warning, the iterator methods in this class are not reentrant.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cai(int width, int horizon)
Return a curve that having values that are the current annual increment of this curve.copy(double factor)
int
count()
delta(double offset)
Return a curve that shows the difference from an offset.void
boolean
double
getXatY(double y)
Get the first X value for a specified value of Ydouble
getY(double x)
Get the Y value at the specified value of Xboolean
hasNext()
insert(double x, double y)
Insert a point in to the curve in sorted order.boolean
isZero(double tolerance)
iterator()
mai(int width, int horizon)
Return a curve that having values that are the mean annual increment of this curve.double
maxX()
Get the maximum X valuedouble
maxY()
Get the maximum Y valuedouble
minX()
Get the minimum X valuedouble
minY()
Get the minimum Y valuevoid
next()
void
void
remove()
void
shiftX(double value)
static int
thin(double[] x, double[] y, int n, double tolerance)
Douglas Peucker recursive in place line thinningtoString()
trim(double beginLimit, double endLimit)
Return a curve that will trim this curve o exclude values before and after the specified limits.truncate(double limit)
Return a curve that will flat-line the this curve at a given value along the entire length of the curve.truncate(double limit, boolean fromEnd)
Return a curve that will flat-line the this curve at a given value, either at the start or end of the curve depending on the setting of the fromEnd parameter.void
visit(Curve curve, double shift, double factor, Curve.Visitor visitor)
Visit this curve with aCurve.Visitor
method.weedcopy(double tolerance)
Thin a copy of a line to a given tolerance, leaving the original untouched.double
ytp()
Return the age of the highest point on the curvestatic Curve
zero()
Return a zero value curveMethods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
Curve
public Curve()Construct a curve with no points -
Curve
public Curve(double y)Construct a curve with a single point at x=0 -
Curve
public Curve(double x, double y)Construct a single point
-
-
Method Details
-
ytp
public double ytp()Return the age of the highest point on the curve -
mai
Return a curve that having values that are the mean annual increment of this curve. -
cai
Return a curve that having values that are the current annual increment of this curve. -
delta
Return a curve that shows the difference from an offset. -
trim
Return a curve that will trim this curve o exclude values before and after the specified limits.- Parameters:
beginLimit
- the X-value before which the curve should be trimmedendLimit
- the X-value after which the curve should be trimmed
-
truncate
Return a curve that will flat-line the this curve at a given value, either at the start or end of the curve depending on the setting of the fromEnd parameter.- Parameters:
limit
- the Y-value where the curve flattening should beginfromEnd
- if true then flatten the end of the curve after reaching the last value of limit. If false then flatten the beginning of the curve up to the point where the first limit value is encountered.
-
truncate
Return a curve that will flat-line the this curve at a given value along the entire length of the curve.- Parameters:
limit
- the Y-value where the curve flattening should begin
-
insert
Insert a point in to the curve in sorted order. -
visit
Visit this curve with aCurve.Visitor
method. -
add
-
multiply
-
divide
-
remainder
-
copy
-
minX
public double minX()Get the minimum X value -
maxX
public double maxX()Get the maximum X value -
minY
public double minY()Get the minimum Y value -
maxY
public double maxY()Get the maximum Y value -
getY
public double getY(double x)Get the Y value at the specified value of X -
getXatY
public double getXatY(double y)Get the first X value for a specified value of Y -
shiftX
public final void shiftX(double value) -
isZero
public boolean isZero(double tolerance) -
count
public int count() -
weedcopy
Thin a copy of a line to a given tolerance, leaving the original untouched. -
thin
public static int thin(double[] x, double[] y, int n, double tolerance)Douglas Peucker recursive in place line thinning -
toString
-
iterator
-
hasNext
public final boolean hasNext()- Specified by:
hasNext
in interfaceIterator<CurvePoint>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<CurvePoint>
-
next
- Specified by:
next
in interfaceIterator<CurvePoint>
-
zero
Return a zero value curve -
operable
-
equals
-