- All Implemented Interfaces:
Shape
,Serializable
,Cloneable
A typical use of this class occurs in the anim2d package for computing the position of an object along a specified path as a function of time.
The constructors are the same as those provided by
SplinePath2D
.
This class is a subclass of Path2D.Double
and
a number of the methods this class calls are final methods and thus
cannot be overridden. The method clear()
should be used instead
of Path2D.reset()
and the method
refresh()
must be called if the path is modified after various
methods are called. See the documentation for refresh()
for
details.
Normally a BasicSplinePath2D will be initialized and then used without any further modifications: this class is intended for cases where an object of some sort follows a path, so the path will usually be created and not modified.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Class representing a location along a path that is an instance of BasicSplinePath2D.Nested classes/interfaces inherited from class java.awt.geom.Path2D
Path2D.Double, Path2D.Float
-
Field Summary
Fields inherited from class java.awt.geom.Path2D
WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty BasicSplinePath2D object with a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays of x and y coordinates given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(int rule) Constructs a new empty BasicSplinePath2D object with the specified winding rule to control operations that require the interior of the path to be defined.BasicSplinePath2D
(int rule, double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays of x and y coordinates and specifying a winding rule.BasicSplinePath2D
(int rule, double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates and specifying a winding rule.BasicSplinePath2D
(int rule, int initialCapacity) Constructs a new empty BasicSplinePath2D object with the specified winding rule and the specified initial capacity to store path segments.BasicSplinePath2D
(int rule, int initialCapacity, double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates with the specified winding rule and initial capacity for storing segments.BasicSplinePath2D
(int rule, int initialCapacity, double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates with the specified winding rule and initial capacity for storing segments.BasicSplinePath2D
(int rule, int initialCapacity, Point2D[] pk, boolean closed) Constructs a new BasicSplinePath2D object from an array of points, given a winding rule and initial capacity.BasicSplinePath2D
(int rule, int initialCapacity, Point2D[] pk, int n, boolean closed) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule and initial capacity.BasicSplinePath2D
(int rule, int initialCapacity, Point2D[] pk, int n, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule, initial capacity, and two control points.BasicSplinePath2D
(int rule, int initialCapacity, Point2D[] pk, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array of points, given a winding rule, initial capacity, and two control points.BasicSplinePath2D
(int rule, int initialCapacity, CubicSpline xf, CubicSpline yf, boolean closed) Constructs a new BasicSplinePath2D object given cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(int rule, int initialCapacity, RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) Constructs a new BasicSplinePath2D object from functions giving x and y coordinates with the specified winding rule and initial capacity for storing segments.BasicSplinePath2D
(int rule, Point2D[] pk, boolean closed) Constructs a new BasicSplinePath2D object from an array of points, given a winding rule.BasicSplinePath2D
(int rule, Point2D[] pk, int n, boolean closed) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule.BasicSplinePath2D
(int rule, Point2D[] pk, int n, Point2D cpoint1, Point2D cpoint2) Constructs a new Basic SplinePath2D object from an array containing at least n points, given a winding rule and two control points.BasicSplinePath2D
(int rule, Point2D[] pk, Point2D cpoint1, Point2D cpoint2) Constructs a new SplinePath2D object from an array of points, given a winding rule and initial and final control points.BasicSplinePath2D
(int rule, CubicSpline xf, CubicSpline yf, boolean closed) Constructs a new BasicSplinePath2D object given cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(int rule, RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays of x and y coordinates and specifying a winding rule.BasicSplinePath2D
(Point2D[] pk, boolean closed) Constructs a new BasicSplinePath2D object from an array of points, given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(Point2D[] pk, int n, boolean closed) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(Point2D[] pk, int n, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a default winding rule ofWIND_NON_ZERO
and two control points.BasicSplinePath2D
(Point2D[] pk, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array of points, given a default winding rule ofWIND_NON_ZERO
and initial and final control points.Constructs a new BasicSplinePath2D object from an arbitraryShape
object.Constructs a new BasicSplinePath2D object from an arbitraryShape
object, transformed by anAffineTransform
object.BasicSplinePath2D
(CubicSpline xf, CubicSpline yf, boolean closed) Constructs a new BasicSplinePath2D object cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
.BasicSplinePath2D
(RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) Constructs a new BasicSplinePath2D object given functions specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
.. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCycle
(double[] x, double[] y) Add a sequence of segments that form a spline, specified as arrays of x and y coordinates, forming a closed path starting at index 0.void
addCycle
(double[] x, double[] y, int n) Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates, forming a closed path starting at index 0.void
Add a sequence of segments that form a spline, specified as Point2D arguments to the addCycle method, and forming a closed path starting at index 0.void
Add a sequence of segments that form a spline, specified as an array of at least n points, forming a closed path starting at index 0.void
append
(CubicSpline xf, CubicSpline yf, boolean connect) Append a spline to this path.void
clear()
Reset the path so that it contains no entries.double
curvature
(double u) Compute the curvature given path parameter.boolean
curvatureExists
(double u) Determine if the curvature exists at the point along the path corresponding to a value of the path parameter.void
cycleTo
(double[] x, double[] y) Add a sequence of segments that form a spline, specified as arrays of x and y coordinates, forming a smooth closed path.void
cycleTo
(double[] x, double[] y, int n) Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates, forming a smooth closed path.void
Add a sequence of segments that form a spline, specified as Point2D arguments to the cycleTo method, and forming a smooth closed path.void
Add a sequence of segments that form a spline, specified as an array of points, forming a smooth closed path.void
cycleTo
(RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n) Add a sequence of segments that form a spline, specified as functions giving the x and y coordinates of points along the path and forming a smooth closed path.double
d2sDu2
(double u) Get the second derivative of the path length with respect to the parameter for a given value of the parameter.double
d2xDu2
(double u) Get the second derivative of the x coordinate with respect to the parameter for a given value of the parameter.double
d2yDu2
(double u) Get the second derivative of the y coordinate with respect to the parameter.double
dsDu
(double u) Get the derivative of the path length with respect to the parameter for a given value of the parameter.double
dxDu
(double u) Get the derivative of the x coordinate with respect to the parameter for a given value of the parameter.double
dyDu
(double u) Get the derivative of the y coordinate with respect to the parameter.boolean
Get the accuracy modedouble
getDistance
(double u1, double u2) Get the distance traversed on a subpath.int
Get the number of intervals used for the cubic splines that map path parameters to the distance along the curve.double
Get the inversion limit.getLocation
(double u) Get a location for a path parameter;double
Get the maximum value of the path parameter.boolean
getNormal
(double u, double[] array) Get the normal vector for a given value of the path parameter.boolean
getNormal
(double u, double[] array, int offset) Get the normal vector for a given value of the path parameter and an offset for the array storing the normal vector.double
Get the total length of the path.double
getPathLength
(double u1, double u2) Get the length of a subpath.getPoint
(double u) Get the point on a path corresponding to a given value of the parameter.int
getSegment
(int i, double[] coords) Get the control points and mode for a segment.boolean
getTangent
(double u, double[] array) Get the tangent vector for a specified value of the path parameter.boolean
getTangent
(double u, double[] array, int offset) Get the tangent vector for a specified value of the path parameter and an output-array offset.double
getX
(double u) Get the x coordinate for a given value of the parameter.double
getY
(double u) Get the y coordinate for a given value of the parameter.boolean
isClosed()
Determine if the path is a closed path.void
Print information about the segments that make up the path to the standard output.void
printTable
(Appendable appendable) Print information about the segments that make up the path.void
printTable
(String prefix, Appendable appendable) Print information about the segments that make up the path, adding a prefix.void
refresh()
Refresh the tables used to map the parameter to x and y coordinates and used to determine lengths and distances, etc.double
s
(double u) Get the distance along a path from its start for a specified path parameter.void
setAccuracyMode
(boolean mode) Set the accuracy mode.void
setIntervalNumber
(int value) Set the number of intervals used for cubic splines.void
setInversionLimit
(double limit) Set the inversion limit.void
splineTo
(double[] x, double[] y) Add a sequence of segments that form a spline, specified as arrays of x and y coordinates.void
splineTo
(double[] x, double[] y, int n) Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates.void
Add a sequence of segments that form a spline, specified as arguments passed to the splineTo method.void
Add a sequence of segments that form a spline, specified as an array of points.void
splineTo
(RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n) Add a sequence of segments that form a spline, specified as functions giving the x and y coordinates.double
u
(double s) Get the path parameter corresponding to a specified distance along a path from its start.Methods inherited from class org.bzdev.geom.SplinePath2D
splineTo, splineTo, splineTo, splineTo
Methods inherited from class java.awt.geom.Path2D.Double
append, clone, curveTo, getBounds2D, getPathIterator, lineTo, moveTo, quadTo, transform, trimToSize
Methods inherited from class java.awt.geom.Path2D
append, closePath, contains, contains, contains, contains, contains, contains, contains, contains, createTransformedShape, getBounds, getCurrentPoint, getPathIterator, getWindingRule, intersects, intersects, intersects, intersects, reset, setWindingRule
-
Constructor Details
-
BasicSplinePath2D
public BasicSplinePath2D()Constructs a new empty BasicSplinePath2D object with a default winding rule ofWIND_NON_ZERO
. -
BasicSplinePath2D
public BasicSplinePath2D(int rule) Constructs a new empty BasicSplinePath2D object with the specified winding rule to control operations that require the interior of the path to be defined.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity) Constructs a new empty BasicSplinePath2D object with the specified winding rule and the specified initial capacity to store path segments.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the path- See Also:
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an arbitraryShape
object.- Parameters:
s
- the specified Shape object
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an arbitraryShape
object, transformed by anAffineTransform
object.- Parameters:
s
- the specified Shape objectat
- the specified AffineTransform object
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array containing at least n points, given a default winding rule ofWIND_NON_ZERO
. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array containing at least n points, given a default winding rule ofWIND_NON_ZERO
and two control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)cpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array of points, given a default winding rule ofWIND_NON_ZERO
. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
pk
- the array of points that make up the knots of a splineclosed
- true if the spline forms a closed path; false otherwise
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array of points, given a default winding rule ofWIND_NON_ZERO
and initial and final control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
pk
- the array of points that make up the knots of a splinecpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
Constructs a new Basic SplinePath2D object from an array containing at least n points, given a winding rule and two control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through. When closed, the initial point should not be repeated by the final point.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)cpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path- See Also:
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array of points, given a winding rule. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)pk
- the array of points that make up the knots of a splineclosed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
Constructs a new SplinePath2D object from an array of points, given a winding rule and initial and final control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through. When closed, the initial point should not be repeated by the final point.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)pk
- the array of points that make up the knots of a splinecpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path- See Also:
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule and initial capacity. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathpk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, Point2D[] pk, int n, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array containing at least n points, given a winding rule, initial capacity, and two control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through. When closed, the initial point should not be repeated by the final point.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathpk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)cpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path- See Also:
-
BasicSplinePath2D
Constructs a new BasicSplinePath2D object from an array of points, given a winding rule and initial capacity. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathpk
- the array of points that make up the knots of a splineclosed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, Point2D[] pk, Point2D cpoint1, Point2D cpoint2) Constructs a new BasicSplinePath2D object from an array of points, given a winding rule, initial capacity, and two control points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through. When closed, the initial point should not be repeated by the final point.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathpk
- the array of points that make up the knots of a splinecpoint1
- the control point just after the start of the pathcpoint2
- the control point just before the end of the path- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates given a default winding rule ofWIND_NON_ZERO
. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise
-
BasicSplinePath2D
public BasicSplinePath2D(double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays of x and y coordinates given a default winding rule ofWIND_NON_ZERO
. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates and specifying a winding rule. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays of x and y coordinates and specifying a winding rule. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, double[] x, double[] y, int n, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates with the specified winding rule and initial capacity for storing segments. The arrays specify the x and y coordinates of the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathx
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)closed
- true if the spline forms a closed path; false otherwise- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, double[] x, double[] y, boolean closed) Constructs a new BasicSplinePath2D object from arrays containing at least n x and y coordinates with the specified winding rule and initial capacity for storing segments. The arrays specify the x and y coordinates of the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathx
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(CubicSpline xf, CubicSpline yf, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
. the functions must be instances ofCubicSpline
and must be created with the same number of "knots". The argument to each function will be rescaled so that it will be incremented by 1.0 when moving from one knot to the next. If closed is true and the initial knot is not at the same location as the final knot, a straight line segment will be used to close the path.This constructor is provided to support cases where the default algorithm for creating a spline is not appropriate: the class
CubicSpline
allows one to specify a number of types of splines, with most differing in how the ends are treated, but with one case (A Hermite spline) explicitly giving the derivative at each knot.- Parameters:
xf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to useclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- The functions xf and yf were not instances ofCubicSpline
or did not have the same number of knots
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, CubicSpline xf, CubicSpline yf, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object given cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
. the functions must be instances ofCubicSpline
and must be created with the same number of "knots". The argument to each function will be rescaled so that it will be incremented by 1.0 when moving from one knot to the next. If closed is true and the initial knot is not at the same location as the final knot, a straight line segment will be used to close the path.This constructor is provided to support cases where the default algorithm for creating a spline is not appropriate: the class
CubicSpline
allows one to specify a number of types of splines, with most differing in how the ends are treated, but with one case (A Hermite spline) explicitly giving the derivative at each knot.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)xf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to useclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- The functions xf and yf were Not instances ofCubicSpline
or did not have the same number of knots
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, CubicSpline xf, CubicSpline yf, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object given cubic splines specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
. the functions must be instances ofCubicSpline
and must be created with the same number of "knots". The argument to each function will be rescaled so that it will be incremented by 1.0 when moving from one knot to the next. The path will be constructed using the control points associated with the cubic splines providing the x and y coordinates. If closed is true and the initial knot is not at the same location as the final knot, a straight line segment will be used to close the path.This constructor is provided to support cases where the default algorithm for creating a spline is not appropriate: the class
CubicSpline
allows one to specify a number of types of splines, with most differing in how the ends are treated, but with one case (A Hermite spline) explicitly giving the derivative at each knot.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathxf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to useclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- The functions xf and yf were not instances ofCubicSpline
or did not have the same number of knots
-
BasicSplinePath2D
public BasicSplinePath2D(RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object given functions specifying the x and y coordinates and given a default winding rule ofWIND_NON_ZERO
..- Parameters:
xf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to uset1
- an end point for the domain of the argument of xf and yft2
- the other end point for the domain of the argument of xf and yfn
- the number of segments between the points at which to evaluate the functionsclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because n was not positive or either t1 or t2 were not in the domain of xf or yf.
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object from arrays of x and y coordinates and specifying a winding rule. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)xf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to uset1
- an end point for the domain of the argument of xf and yft2
- the other end point for the domain of the argument of xf and yfn
- the number of segments between the points at which to evaluate the functionsclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because n was not positive or either t1 or t2 were not in the domain of xf or yf.- See Also:
-
BasicSplinePath2D
public BasicSplinePath2D(int rule, int initialCapacity, RealValuedFunctOps xf, RealValuedFunctOps yf, double t1, double t2, int n, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath2D object from functions giving x and y coordinates with the specified winding rule and initial capacity for storing segments.- Parameters:
rule
- the winding rule (WIND_EVEN_ODD
orWIND_NON_ZERO
)initialCapacity
- an estimate for the number of path segments in the pathxf
- the function specifying the x coordinates to useyf
- the function specifying the y coordinates to uset1
- an end point for the domain of the argument of xf and yft2
- the other end point for the domain of the argument of xf and yfn
- the number of segments between the points at which to evaluate the functionsclosed
- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException
- the arguments were illegal, typically because n was not positive or either t1 or t2 were not in the domain of xf or yf.- See Also:
-
-
Method Details
-
isClosed
public boolean isClosed()Determine if the path is a closed path.- Returns:
- true if it is closed; false if it is not closed
-
setIntervalNumber
public void setIntervalNumber(int value) Set the number of intervals used for cubic splines. For each path segment, a cubic spline is used to determine the distance from the start of the path to a point along the path represented by a path parameter. This method sets the number of points used to construct this spline. The default value (64) should be adequate for most purposes. A smaller value reduces memory usage but decreases accuracy.- Parameters:
value
- the number of intervals (must be larger than 4) or 0 for the default
-
getIntervalNumber
public int getIntervalNumber()Get the number of intervals used for the cubic splines that map path parameters to the distance along the curve. For each path segment, a cubic spline is used to determine the distance from the start of the path to a point along the path represented by a path parameter. This method returns the number of points used to construct this spline.- Returns:
- the number of intervals
-
printTable
public void printTable()Print information about the segments that make up the path to the standard output. Entry i contains the x and y coordinate when the parameter is equal to i, followed by control points, the last of which is the coordinate when the parameter is i+1. Each segment represents a line or curve whose intermediate points, if any, are control points. -
printTable
Print information about the segments that make up the path. Entry i contains the x and y coordinate when the parameter is equal to i, followed by control points, the last of which is the coordinate when the parameter is i+1. Each segment represents a line or curve whose intermediate points, if any, are control points.- Parameters:
appendable
- an Appendable on which to print
-
printTable
Print information about the segments that make up the path, adding a prefix. Entry i contains the x and y coordinate when the parameter is equal to i, followed by control points, the last of which is the coordinate when the parameter is i+1. Each segment represents a line or curve whose intermediate points, if any, are control points.- Parameters:
prefix
- a prefix to print at the start of each line (null implies an empty string)appendable
- the appendable for output
-
getMaxParameter
public double getMaxParameter()Get the maximum value of the path parameter. This value is directly applicable for open paths, not closed paths. For closed paths, it represents the period at which the path is guaranteed to repeat. The returned value is numerically equal to the number of segments that make up the path.- Returns:
- the maximum value of the parameter
-
getLocation
Get a location for a path parameter;- Parameters:
u
- the path parameter- Returns:
- the location
-
getX
Get the x coordinate for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the x coordinate of the point on the path for the specified parameter
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
getY
Get the y coordinate for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the y coordinate of the point on the path for the specified parameter
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
getPoint
Get the point on a path corresponding to a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the point on the path corresponding to the specified parameter
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
dxDu
Get the derivative of the x coordinate with respect to the parameter for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
dyDu
Get the derivative of the y coordinate with respect to the parameter.- Parameters:
u
- the parameter- Returns:
- the derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
d2xDu2
Get the second derivative of the x coordinate with respect to the parameter for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the second derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
d2yDu2
Get the second derivative of the y coordinate with respect to the parameter.- Parameters:
u
- the parameter- Returns:
- the derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
curvature
Compute the curvature given path parameter. The curvature is given by the expression
where the derivative are computed with respect to the path parameter, and is positive if the path turns counterclockwise as the parameter increases, is negative if the path turns clockwise, and is zero if the path follows a straight line. For this purpose, counterclockwise refers to direction for the shortest rotation from the positive X axis to the positive Y axis clockwise refers to the shortest rotation from the positive Y axis to the positive X axis. Note that this is the reverse of terminology one would use for user space, where the positive X axis points left and the positive Y axis points down. The radius of curvature is the multiplicative inverse of the absolute value of the curvature.(x'y" - y'x")/(xp2 + y'2)3/2
- Parameters:
u
- the path parameter- Returns:
- the curvature
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
curvatureExists
public boolean curvatureExists(double u) Determine if the curvature exists at the point along the path corresponding to a value of the path parameter. In general, the curvature does not exist when all the points along a segment are the same point or when the segment is a SEG_MOVETO segment (which just indicates the start of a curve). For a SEG_CLOSE segment where the starting and ending points are identical, the curvature exists if the curvature of the previous segment exists at its end (u = 1.0).- Parameters:
u
- the path parameter- Returns:
- true if the curvature exists; false otherwise
- Throws:
IllegalStateException
- this location is no longer valid
-
getTangent
public boolean getTangent(double u, double[] array) Get the tangent vector for a specified value of the path parameter. If the tangent vector does not exist (e.g., the length of the line does not vary with the path parameter), the tangent vector will be set to zero. The tangent vector will have unit length if it is not zero.- Parameters:
u
- the path parameterarray
- an array of length no less than 2 used to store the tangent vector, with array[0] containing the tangent vector's X component and array[1] containing the tangent vector's Y component- Returns:
- true if the tangent vector exists; false if the tangent vector does not exist
-
getTangent
public boolean getTangent(double u, double[] array, int offset) Get the tangent vector for a specified value of the path parameter and an output-array offset. If the tangent vector does not exist (e.g., the length of the line does not vary with the path parameter), the tangent vector will be set to zero. The tangent vector will have unit length if it is not zero.- Parameters:
u
- the path parameterarray
- an array of length no less than 2 used to store the tangent vector, with array[offset] containing the tangent vector's X component and array[offset+1] containing the tangent vector's Y componentoffset
- the index into the array at which to store the tangent vector- Returns:
- true if the tangent vector exists; false if the tangent vector does not exist
-
getNormal
public boolean getNormal(double u, double[] array) Get the normal vector for a given value of the path parameter. The normal vector N is a vector of unit length, perpendicular to the tangent vector, and oriented so that d2r/ds2 = κN where κ is the (signed) curvature. If the normal vector does not exist (e.g., the length of the line does not vary with the path parameter), the normal vector will be set to zero.Note: the use of the signed curvature results in the normal vector always pointing in the counter-clockwise direction (i.e., a rotating the X axis towards the Y axis). This allows a normal vector exist for straight-line segments. A different definition is used for 3D paths.
- Parameters:
u
- the path parameterarray
- an array of length no less than 2 used to store the normal vector, with array[0] containing the normal vector's X component and array[1] containing the normal vector's Y component- Returns:
- true if the normal vector exists; false if the normal vector does not exist
-
getNormal
public boolean getNormal(double u, double[] array, int offset) Get the normal vector for a given value of the path parameter and an offset for the array storing the normal vector. The normal vector N is a vector of unit length, perpendicular to the tangent vector, and oriented so that d2r/ds2 = κN where κ is the (signed) curvature. If the normal vector does not exist (e.g., the length of the line does not vary with the path parameter), the normal vector will be set to zero.Note: the use of the signed curvature results in the normal vector always pointing in the counter-clockwise direction (i.e., a rotating the X axis towards the Y axis). This allows a normal vector exist for straight-line segments. A different definition is used for 3D paths.
- Parameters:
u
- the path parameterarray
- an array of length no less than 2 used to store the normal vector, with array[offset] containing the normal vector's X component and array[offset+1] containing the normal vector's Y componentoffset
- the array offset- Returns:
- true if the normal vector exists; false if the normal vector does not exist
-
dsDu
Get the derivative of the path length with respect to the parameter for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
d2sDu2
Get the second derivative of the path length with respect to the parameter for a given value of the parameter.- Parameters:
u
- the parameter- Returns:
- the second derivative
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
getInversionLimit
public double getInversionLimit()Get the inversion limit. The inversion limit (a negative number indicates that the default should be used) is used by cubic splines used to map path distances to path parameters. The value supplied is used when a spline is created.Computing the inverse for a cubic spline in most cases requires solving a cubic equation, with valid solutions being in the range [0, 1]. The inversion limit allows solutions in the range [-inversionLimit, 1+inversionLimit] to be accepted, with values outside of the interval [0, 1] replaced by 0 or 1, whichever is closer. The use of an inversion limit allows for round-off errors.
- Returns:
- the inversion limit
-
setInversionLimit
public void setInversionLimit(double limit) Set the inversion limit. The inversion limit (a negative number indicates that the default should be used) is used by cubic splines used to map path distances to path parameters. The value supplied is used when a spline is created.Computing the inverse for a cubic spline in most cases requires solving a cubic equation, with valid solutions being in the range [0, 1]. The inversion limit allows solutions in the range [-inversionLimit, 1+inversionLimit] to be accepted, with values outside of the interval [0, 1] replaced by 0 or 1, whichever is closer. The use of an inversion limit allows for round-off errors.
- Parameters:
limit
- the inversion limit; or a negative number to indicate that the default will be used.
-
getSegment
Get the control points and mode for a segment. The segments are in the same order as those returned by a path iterator, but do not include an initialPathIterator.SEG_MOVETO
segment nor a terminatingPathIterator.SEG_CLOSE
segment. There are two control points for linear segments, three for quadratic Bézier curve segments, and four for cubic Bézier curve segments. Path iterators do not provide the 0th control point for these cases directly—instead the caller has to use the final control point obtained for the previous iteration.- Parameters:
i
- the segment index specified by an integer in the range [0, n) where n is the number of segmentscoords
- an array of at least 8 elements that will contain the control points, each represented by two successive array elements with the X coordinate appearing before the Y coordinate- Returns:
- the mode for the segment
(
PathIterator.SEG_LINETO
,PathIterator.SEG_QUADTO
, orPathIterator.SEG_CUBICTO
) - Throws:
IllegalArgumentException
-
getPathLength
Get the total length of the path.- Returns:
- the path length
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
getPathLength
public double getPathLength(double u1, double u2) throws IllegalStateException, IllegalArgumentException Get the length of a subpath. The returned value is the same if u1 and u2 are exchanged: lengths are non-negative.- Parameters:
u1
- the parameter at the first end point of a subpathu2
- the parameter at the second end point of a subpath- Returns:
- the length of the subpath
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
setAccuracyMode
public void setAccuracyMode(boolean mode) Set the accuracy mode. The accuracy mode determines how distances are computed from path parameters and how distances along a path are converted to path parameters. When the mode is set to true, a slower, but more accurate computation is done. When false, precomputed splines are used. For typical animations, the valuefalse
is appropriate.- Parameters:
mode
- true for enhanced accuracy; false for normal accuracy
-
getAccuracyMode
public boolean getAccuracyMode()Get the accuracy mode- Returns:
- true for more accuracy; false for 'normal' accuracy
- See Also:
-
getDistance
public double getDistance(double u1, double u2) throws IllegalStateException, IllegalArgumentException Get the distance traversed on a subpath. If u2 < u1, the value returned is negative.This is intended for cases where direction is important.
- Parameters:
u1
- the parameter at the first end point of a subpathu2
- the parameter at the second end point of a subpath- Returns:
- the distance traversed on a subpath
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
s
Get the distance along a path from its start for a specified path parameter. The argument may be negative for cyclic paths, in which case the value returned will also be non-positive.- Parameters:
u
- the path parameter- Returns:
- the distance along a path from its start
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
u
Get the path parameter corresponding to a specified distance along a path from its start.- Parameters:
s
- the distance along a path from its start- Returns:
- the path parameter
- Throws:
IllegalStateException
- the path is not a simple pathIllegalArgumentException
- the parameter is out of bounds
-
clear
public void clear()Reset the path so that it contains no entries. This method should be used instead ofPath2D.reset()
, which cannot be overridden due to being declared as final. -
refresh
Refresh the tables used to map the parameter to x and y coordinates and used to determine lengths and distances, etc. If the path is modified using aPath2D
method after any of theSplinePath2D
methodsgetX(double)
getY(double)
dxDu(double)
dyDu(double)
d2xDu2(double)
d2yDu2(double)
dsDu(double)
d2sDu2(double)
curvature(double)
s(double)
u(double)
isClosed()
getPathLength()
getPathLength(double,double)
getDistance(double,double)
refresh()
must be called. ThePath2D
} that modify a path are the following:Path2D.Double.append(PathIterator,boolean)
Path2D.Double.curveTo(double,double,double,double,double,double)
Path2D.Double.lineTo(double,double)
Path2D.Double.moveTo(double,double)
Path2D.Double.quadTo(double,double,double,double)
Path2D.Double.transform(AffineTransform)
Path2D.append(Shape,boolean)
Path2D.closePath()
Path2D.reset()
(which should not be used for reasons described below).
clear()
callsPath2D.reset()
but also reinitializes the path so that refresh() does not have to be called if segments are added after the call toclear()
but before any of the methods in the list starting withgetX(double)
are called. The methodPath2D.reset()
should not be used directly when an explicit call torefresh()
would be needed. Unfortunately,Path2D.reset()
is a final method, and consequently cannot be overridden to produce the desired behavior.- Throws:
IllegalStateException
-
addCycle
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of x and y coordinates, forming a closed path starting at index 0. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is (x[0], y[0]) and there is an implicit moveTo operation for this point, which should not be repeated by the point specified by the last arguments of the x and y arrays.- Overrides:
addCycle
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knot- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ
-
addCycle
public void addCycle(double[] x, double[] y, int n) Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates, forming a closed path starting at index 0. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is (x[0], y[0]) and there is an implicit moveTo operation for this point, which should not be repeated by the point specified by the array arguments at index n-1.- Overrides:
addCycle
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)
-
addCycle
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as Point2D arguments to the addCycle method, and forming a closed path starting at index 0. The points specify the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is the one specified by the first argument and there is an implicit moveTo operation for this point, which should not be repeated by the last argument.- Overrides:
addCycle
in classSplinePath2D
- Parameters:
points
- the points that make up the knots of a spline
-
addCycle
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as an array of at least n points, forming a closed path starting at index 0. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is pk[0] and there is an implicit moveTo operation for this point, which should not be repeated as the element at index n-1 of the array provided as this method's first argument.- Overrides:
addCycle
in classSplinePath2D
- Parameters:
pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)
-
append
Description copied from class:SplinePath2D
Append a spline to this path. The spline is provided by a CubicSpline for the x coordinates and a CubicSpline for the y coordinates.- Overrides:
append
in classSplinePath2D
- Parameters:
xf
- the cubic spline providing the x coordinatesyf
- the cubic spline providing the y coordinatesconnect
- true if the appended spline is to be connected to this path with a lineTo operation; false if a moveTo operation will be used instead- Throws:
IllegalArgumentException
- the splines xf and yf did not have the same number of knots
-
cycleTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of x and y coordinates, forming a smooth closed path. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.) and there is an implicit moveTo operation to this point. The point specified by the last elements in the x and y arrays should not repeat this initial point. The implicit moveTo may result in the path containing multiple moveTo segments back to back.- Overrides:
cycleTo
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knot- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ
-
cycleTo
public void cycleTo(double[] x, double[] y, int n) Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates, forming a smooth closed path. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.) and there is an implicit moveTo operation to this point. The point specified by the array index n-1 should not repeat this initial point. The implicit moveTo may result in the path containing multiple moveTo segments back to back.- Overrides:
cycleTo
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)
-
cycleTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as Point2D arguments to the cycleTo method, and forming a smooth closed path. The points specify the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.). The last argument should not repeat this initial point.- Overrides:
cycleTo
in classSplinePath2D
- Parameters:
points
- the points that make up the knots of a spline
-
cycleTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as an array of points, forming a smooth closed path. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at all points. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.) and there is an implicit moveTo operation to this point. Element n-1 in the array pk should not repeat this initial point. The implicit moveTo may result in the path containing multiple moveTo segments back to back.- Overrides:
cycleTo
in classSplinePath2D
- Parameters:
pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)
-
cycleTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as functions giving the x and y coordinates of points along the path and forming a smooth closed path.The "knots" of the spline - the points the spline is constrained to pass through - are are at evenly spaced values of the argument passed to the functions, and the spline will have matching first and second derivatives at all points. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.) and there is an implicit moveTo operation to this point. The end points at t1 and t2 are included as knots. The end point at t2 should not repeat the initial point. The implicit moveTo may result in the path containing multiple moveTo segments back to back.
The number of segments is one less than the number of points so that n=2 implies that the function will be evaluated at t1, t2, and (t1 + t2)/2.
- Overrides:
cycleTo
in classSplinePath2D
- Parameters:
xf
- the function giving the x coordinates for the path segmentyf
- the function giving the y coordinates for the path segmentt1
- an end point for the domain of the argument of xf and yft2
- the other end point for the domain of the argument of xf and yfn
- the number of segments between points at which to evaluate the functions
-
splineTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of x and y coordinates. The arrays specify the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at intermediate points. At the end points, the direction of the tangent line points towards the adjacent knot. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.).- Overrides:
splineTo
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knot- Throws:
IllegalArgumentException
- the arguments were illegal, typically because the lengths of the arrays differ
-
splineTo
public void splineTo(double[] x, double[] y, int n) Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arrays of at least n x and y coordinates. The arrays specify the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at intermediate points. At the end points, the direction of the tangent line points towards the adjacent knot. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.).- Overrides:
splineTo
in classSplinePath2D
- Parameters:
x
- the x coordinates to use, one for each knoty
- the y coordinates to use, one for each knotn
- the number of points in the array to use, with valid indices in the range [0, n)
-
splineTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as arguments passed to the splineTo method. The arguments specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at intermediate points. At the end points, the direction of the tangent line points towards the adjacent knot. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.).- Overrides:
splineTo
in classSplinePath2D
- Parameters:
points
- the array of points that make up the knots of a spline
-
splineTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as an array of points. The array specifies the "knots" of the spline - the points the spline is constrained to pass through - and the spline will have matching first and second derivatives at intermediate points. At the end points, the direction of the tangent line points towards the adjacent knot. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.).- Overrides:
splineTo
in classSplinePath2D
- Parameters:
pk
- the array of points that make up the knots of a splinen
- the number of points in the array to use, with valid indices in the range [0, n)
-
splineTo
Description copied from class:SplinePath2D
Add a sequence of segments that form a spline, specified as functions giving the x and y coordinates. The "knots" of the spline - the points the spline is constrained to pass through - are at evenly spaced values of the argument passed to the functions, and the spline will have matching first and second derivatives at intermediate points. At the end points, the direction of the tangent line points towards the adjacent knot. The initial point is the one previously added to the path via some other method (e.g., moveTo, lineTo, etc.). The end points at t1 and t2 are included as knots.The number of segments is one less than the number of points so that n=2 implies that the function will be evaluated at t1, t2, and (t1 + t2)/2.
- Overrides:
splineTo
in classSplinePath2D
- Parameters:
xf
- the function giving the x coordinates for the path segmentyf
- the function giving the y coordinates for the path segmentt1
- an end point for the domain of the argument of xf and yft2
- the other end point for the domain of the argument of xf and yfn
- the number of segments between the points at which to evaluate the functions
-