- All Implemented Interfaces:
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
SplinePath3D.
This class is a subclass of Path3D.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 Path3D.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 BasicSplinePath3D 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 TypeClassDescriptionclassClass representing a location along a path that is an instance of BasicSplinePath3D.Nested classes/interfaces inherited from class org.bzdev.geom.Path3D
Path3D.Double, Path3D.Float -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new empty BasicSplinePath3D object.BasicSplinePath3D(double[] x, double[] y, double[] z, boolean closed) Constructs a new BasicSplinePath3D object from arrays of x and y coordinates.BasicSplinePath3D(double[] x, double[] y, double[] z, int n, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates.BasicSplinePath3D(int initialCapacity) Constructs a new empty BasicSplinePath3D object with the specified initial capacity to store path segments.BasicSplinePath3D(int initialCapacity, double[] x, double[] y, double[] z, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates with the specified initial capacity for storing segments.BasicSplinePath3D(int initialCapacity, double[] x, double[] y, double[] z, int n, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates with the specified initial capacity for storing segments.BasicSplinePath3D(int initialCapacity, Point3D[] pk, boolean closed) Constructs a new BasicSplinePath3D object from an array of points, given an initial capacity.BasicSplinePath3D(int initialCapacity, Point3D[] pk, int n, boolean closed) Constructs a new BasicSplinePath3D object from an array containing at least n points, given an initial capacity.BasicSplinePath3D(int initialCapacity, CubicSpline xf, CubicSpline yf, CubicSpline zf, boolean closed) Constructs a new BasicSplinePath3D object given cubic splines specifying the x, y and z coordinates and an initial capacity.BasicSplinePath3D(int initialCapacity, RealValuedFunctOps xf, RealValuedFunctOps yf, RealValuedFunctOps zf, double t1, double t2, int n, boolean closed) Constructs a new SplinePath3D object from functions giving X, Y, and Z coordinates, and the initial capacity for storing segments.BasicSplinePath3D(Path3D path) Constructor using another path to determine the initial path segments.BasicSplinePath3D(Path3D path, Transform3D transform) Constructor using another path to determine the initial path segments, modified with a 3D transform.BasicSplinePath3D(Point3D[] pk, boolean closed) Constructs a new BasicSplinePath3D object from an array of points.BasicSplinePath3D(Point3D[] pk, int n, boolean closed) Constructs a new BasicSplinePath3D object from an array containing at least n points.BasicSplinePath3D(Point3D[] pk, int offset, int n, Point3D cpoint1, Point3D cpoint2) Constructs a new BasicSplinePath3D object from an array containing at least n knots, starting at an offset, with two control points.BasicSplinePath3D(Point3D[] pk, int n, Point3D cpoint1, Point3D cpoint2) Constructs a new BasicSplinePath3D object from an array containing at least n knots and two control points.BasicSplinePath3D(Point3D[] pk, Point3D cpoint1, Point3D cpoint2) Constructs a new BasicSplinePath3D object from an array of knots and initial and final control points.BasicSplinePath3D(CubicSpline xf, CubicSpline yf, CubicSpline zf, boolean closed) Constructs a new BasicSplinePath3D object given cubic splines specifying the x, y and z coordinates.BasicSplinePath3D(RealValuedFunctOps xf, RealValuedFunctOps yf, RealValuedFunctOps zf, double t1, double t2, int n, boolean closed) Constructs a new SplinePath3D object given functions specifying the X, Y, and Z coordinates. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Reset the path so that it contains no entries.doublecurvature(double u) Compute the curvature given the path parameter.booleancurvatureExists(double u) Determine if the curvature exists at the point along the path corresponding to a value of the path parameter.doubled2sDu2(double u) Get the second derivative of the path length with respect to the parameter for a given value of the parameter.doubled2xDu2(double u) Get the second derivative of the X coordinate with respect to the parameter for a given value of the parameter.doubled2yDu2(double u) Get the second derivative of the Y coordinate with respect to the parameter.doubled2zDu2(double u) Get the second derivative of the Z coordinate with respect to the parameter.doubledsDu(double u) Get the derivative of the path length with respect to the parameter for a given value of the parameter.doubledxDu(double u) Get the derivative of the X coordinate with respect to the parameter for a given value of the parameter.doubledyDu(double u) Get the derivative of the Y coordinate with respect to the parameter.doubledzDu(double u) Get the derivative of the Z coordinate with respect to the parameter.booleanGet the accuracy modebooleangetBinormal(double u, double[] array) Get the binormal vector for a given value of the path parameter.booleangetBinormal(double u, double[] array, int offset) Get the binormal vector for a given value of the path parameter and an offset for the array storing the normal vector.doublegetDistance(double u1, double u2) Get the distance traversed on a subpath.intGet the number of intervals used for cubic splines.doubleGet the inversion limit.getLocation(double u) Get a location for a path parameter;doubleGet the maximum value of the parameter.booleangetNormal(double u, double[] array) Get the normal vector for a given value of the path parameter.booleangetNormal(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.doubleGet the total length of the path.doublegetPathLength(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.intgetSegment(int i, double[] coords) Get the control points and mode for a segment.booleangetTangent(double u, double[] array) Get the tangent vector for a specified value of the path parameter.booleangetTangent(double u, double[] array, int offset) Get the tangent vector for a specified value of the path parameter and an output-array offset.doublegetX(double u) Get the X coordinate for a given value of the parameter.doublegetY(double u) Get the Y coordinate for a given value of the parameter.doublegetZ(double u) Get the Z coordinate for a given value of the parameter.booleanisClosed()Determine if the path is a closed path.voidPrint information about the segments that make up the path to the standard output.voidprintTable(Appendable appendable) Print information about the segments that make up the path.voidprintTable(String prefix, Appendable appendable) Print information about the segments that make up the path adding a prefix.voidrefresh()Refresh the tables used to map the parameter to X, Y, and Z coordinates and used to determine lengths and distances, etc.doubles(double u) Get the distance along a path from its start for a specified path parameter.voidsetAccuracyMode(boolean mode) Set the accuracy mode.voidsetIntervalNumber(int value) Set the number of intervals used for cubic splines.voidsetInversionLimit(double limit) Set the inversion limit.doubletorsion(double u) Compute the torsion given the path parameter.doubleu(double s) Get the path parameter corresponding to a specified distance along a path from its start.Methods inherited from class org.bzdev.geom.SplinePath3D
addCycle, addCycle, addCycle, addCycle, append, cycleTo, cycleTo, cycleTo, cycleTo, cycleTo, splineTo, splineTo, splineTo, splineTo, splineTo, splineTo, splineTo, splineTo, splineToMethods inherited from class org.bzdev.geom.Path3D.Double
append, clone, createTransformedPath, curveTo, getEnd, getPathIterator, getStart, lineTo, moveTo, quadTo, transformMethods inherited from class org.bzdev.geom.Path3D
append, closePath, getBounds, getCurrentPoint, isEmpty, reset, setupCubic, setupCubic, setupCubic, setupCubic
-
Constructor Details
-
BasicSplinePath3D
public BasicSplinePath3D()Constructs a new empty BasicSplinePath3D object. -
BasicSplinePath3D
public BasicSplinePath3D(int initialCapacity) Constructs a new empty BasicSplinePath3D object with the specified initial capacity to store path segments.- Parameters:
initialCapacity- an estimate for the number of path segments in the path
-
BasicSplinePath3D
Constructor using another path to determine the initial path segments.- Parameters:
path- the path whose segments will be copied
-
BasicSplinePath3D
Constructor using another path to determine the initial path segments, modified with a 3D transform.- Parameters:
path- the path whose segments will be copiedtransform- the transform to apply to the path segments
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array containing at least n 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)closed- true if the spline forms a closed path; false otherwise
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array of 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 splineclosed- true if the spline forms a closed path; false otherwise
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array containing at least n points, given an initial capacity. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
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
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array of points, given an initial capacity. The array specifies the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
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
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array containing at least n knots 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
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array containing at least n knots, starting at an offset, with 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 contain the knots of a splineoffset- the offset into the array for the starting knotn- the number of points in the array to use, with valid indices in the range [offset, offset+n)cpoint1- the control point just after the start of the pathcpoint2- the control point just before the end of the path
-
BasicSplinePath3D
Constructs a new BasicSplinePath3D object from an array of knots 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:
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
-
BasicSplinePath3D
public BasicSplinePath3D(double[] x, double[] y, double[] z, int n, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates. 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 knotz- the Z 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
-
BasicSplinePath3D
public BasicSplinePath3D(double[] x, double[] y, double[] z, boolean closed) Constructs a new BasicSplinePath3D object from arrays of x and y coordinates. 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 knotz- the Z 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
-
BasicSplinePath3D
public BasicSplinePath3D(int initialCapacity, double[] x, double[] y, double[] z, int n, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates with the specified initial capacity for storing segments. The arrays specify the X, Y, and Z coordinates of the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
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 knotz- the Z 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
-
BasicSplinePath3D
public BasicSplinePath3D(int initialCapacity, double[] x, double[] y, double[] z, boolean closed) Constructs a new BasicSplinePath3D object from arrays containing at least n X, Y, and Z coordinates with the specified initial capacity for storing segments. The arrays specify the X, Y, and Z coordinates of the "knots" of the spline - the points the spline is constrained to pass through.- Parameters:
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 knotz- the Z 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
-
BasicSplinePath3D
public BasicSplinePath3D(CubicSpline xf, CubicSpline yf, CubicSpline zf, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath3D object given cubic splines specifying the x, y and z coordinates. The functions must be instances ofCubicSplineand 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
CubicSplineallows 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 spline specifying the x coordinates to useyf- the spline specifying the y coordinates to usezf- the spline specifying the y coordinates to useclosed- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException- The splines xf, yf and zf did not have the same number of knots
-
BasicSplinePath3D
public BasicSplinePath3D(int initialCapacity, CubicSpline xf, CubicSpline yf, CubicSpline zf, boolean closed) throws IllegalArgumentException Constructs a new BasicSplinePath3D object given cubic splines specifying the x, y and z coordinates and an initial capacity. The splines 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, y, and z 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
CubicSplineallows 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:
initialCapacity- an estimate for the number of path segments in the pathxf- the spline specifying the x coordinates to useyf- the spline specifying the y coordinates to usezf- the spline specifying the y coordinates to useclosed- true if the spline forms a closed path; false otherwise- Throws:
IllegalArgumentException- The spline xf and yf did not have the same number of knotsIllegalArgumentException- The splines xf, yf and zf did not have the same number of knots
-
BasicSplinePath3D
public BasicSplinePath3D(RealValuedFunctOps xf, RealValuedFunctOps yf, RealValuedFunctOps zf, double t1, double t2, int n, boolean closed) throws IllegalArgumentException Constructs a new SplinePath3D object given functions specifying the X, Y, and Z coordinates.- Parameters:
xf- the function specifying the X coordinates to useyf- the function specifying the Y coordinates to usezf- the function specifying the Z 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.
-
BasicSplinePath3D
public BasicSplinePath3D(int initialCapacity, RealValuedFunctOps xf, RealValuedFunctOps yf, RealValuedFunctOps zf, double t1, double t2, int n, boolean closed) throws IllegalArgumentException Constructs a new SplinePath3D object from functions giving X, Y, and Z coordinates, and the initial capacity for storing segments.- Parameters:
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 usezf- the function specifying the Z 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.
-
-
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 (16) 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 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 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, Y, and Z 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, Y, and Z 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, Y, and Z 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 parameter. This value is applicable for open paths, not closed paths. 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
-
getZ
Get the Z coordinate for a given value of the parameter.- Parameters:
u- the parameter- Returns:
- the Z 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
-
dzDu
Get the derivative of the Z 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
-
d2zDu2
Get the second derivative of the Z 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 the path parameter. The curvature is given by the expression
where the derivative are computed with respect to the path parameter. The radius of curvature is the multiplicative inverse of the absolute value of the curvature.sqrt((z"y'-y"z')2 + (x"z'-z"x')2 + (y"x'-x"y')2) / (x'2 + y'2 + z'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
-
torsion
Compute the torsion given the path parameter. The torsion is given by the expression
where the derivative are computed with respect to the path parameter. The Wikipedia page The Frenet-Serret Formulas contains the equation above in vector form.(x'"(z"y'-y"z') + y"'(x"z'-z"x') + z"'(y"x'-x"y')) / ((y'z"-y"z')2 + (x"z'-x'z")2 + (x'y"-x"y')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 3 used to store the tangent vector, with array[0] containing the tangent vector's X component, array[1] containing the tangent vector's Y component, and array[2] containing the tangent vector's Z 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 3 used to store the tangent vector, with array[offset] containing the tangent vector's X component, array[offset+1] containing the tangent vector's Y component, and array[offset+2] containing the tangent vector's Z 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 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.- 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, array[1] containing the normal vector's Y component, and array[2] containing the normal vector's Z component- Returns:
- true if the normal vector exists; false if the normal vector does not exist
-
getBinormal
public boolean getBinormal(double u, double[] array) Get the binormal vector for a given value of the path parameter. The binormal vector is defined as the cross product T X N of the tangent and normal vectors. If the binormal vector does not exist (e.g., the length of the line does not vary with the path parameter or the path is locally straight), the binormal vector will be set to zero.- 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, array[1] containing the normal vector's Y component, and array[2] containing the normal vector's Z component- Returns:
- true if the binormal 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 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.- Parameters:
u- the path parameterarray- an array of length no less than 3 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 component, and array[offset+2] containing the normal vector's Z componentoffset- the array offset- Returns:
- true if the normal vector exists; false if the normal vector does not exist
-
getBinormal
public boolean getBinormal(double u, double[] array, int offset) Get the binormal vector for a given value of the path parameter and an offset for the array storing the normal vector. The binormal vector is defined as the cross product T X N of the tangent and normal vectors. If the binormal vector does not exist (e.g., the length of the line does not vary with the path parameter or the path is locally straight), the binormal vector will be set to zero.- Parameters:
u- the path parameterarray- an array of length no less than 3 used to store the binormal vector, with array[offset] containing the normal vector's X component and array[offset+1] containing the normal vector's Y component, and array[offset+2] containing the bnormal vector's Z componentoffset- the array offset- Returns:
- true if the binormal 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
public double d2sDu2(double u) 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 initialPathIterator3D.SEG_MOVETOsegment nor a terminatingPathIterator3D.SEG_CLOSEsegment. 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 store the final control point obtained for the previous segment.- 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 12 elements that will contain the control points- Returns:
- the mode for the segment
(
PathIterator3D.SEG_LINETO,PathIterator3D.SEG_QUADTO, orPathIterator3D.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 parh 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 valuefalseis 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 signed distance for 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:
IllegalStateExceptionIllegalArgumentException
-
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:
IllegalStateExceptionIllegalArgumentException
-
clear
public void clear()Reset the path so that it contains no entries. This method should be used instead ofPath3D.reset(), which cannot be overridden due to being declared as final. -
refresh
Refresh the tables used to map the parameter to X, Y, and Z coordinates and used to determine lengths and distances, etc. If the path is modified after any of the methodsgetX(double)getY(double)dxDu(double)dyDu(double)d2xDu2(double)d2yDu2(double)dsDu(double)d2sDu2(double)curvature(double)s(double)u(double)getPathLength()getPathLength(double,double)getDistance(double,double)
refresh()must be called. Paths are modified by callingSplinePath3D.addCycle(double[],double[],double[])SplinePath3D.addCycle(double[],double[],double[],int)SplinePath3D.addCycle(Point3D[])SplinePath3D.addCycle(Point3D[],int)SplinePath3D.cycleTo(double[],double[],double[])SplinePath3D.cycleTo(double[],double[],double[],int)SplinePath3D.cycleTo(Point3D[])SplinePath3D.cycleTo(Point3D[],int)SplinePath3D.cycleTo(org.bzdev.math.RealValuedFunctOps,org.bzdev.math.RealValuedFunctOps,org.bzdev.math.RealValuedFunctOps,double, double,int)SplinePath3D.splineTo(double[],double[],double[])SplinePath3D.splineTo(double[],double[],double[],int)SplinePath3D.splineTo(Point3D[])SplinePath3D.splineTo(Point3D[],int)SplinePath3D.splineTo(org.bzdev.math.RealValuedFunctOps,org.bzdev.math.RealValuedFunctOps,org.bzdev.math.RealValuedFunctOps,double,double,int)Path3D.Double.append(PathIterator3D,boolean)Path3D.Double.curveTo(double,double,double,double,double,double,double,double,double)Path3D.Double.lineTo(double,double,double)Path3D.Double.moveTo(double,double,double)Path3D.Double.quadTo(double,double,double,double, double,double)Path3D.Double.transform(Transform3D)Path3D.append(PathIterator3D,boolean)Path3D.append(Path3D,boolean)Path3D.closePath()Path3D.reset()(which should not be used).clear()
clear()callsPath3D.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.- Throws:
IllegalStateException
-