Class BasicSplinePath3D

All Implemented Interfaces:
Cloneable

public class BasicSplinePath3D extends SplinePath3D
Class representing a continuous path. The path may be opened or closed, but without any gaps. Methods or constructors for splines may be used to create smooth curves. This class extends SplinePath3D by adding methods to determine the X, Y, and Z coordinates of a point given a parameter that starts at 0 and that is incremented by 1 when moving from one segment to another. The paths that can be represented, however, are restricted.

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 Classes
    Modifier and Type
    Class
    Description
    class 
    Class 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

    Constructors
    Constructor
    Description
    Constructs 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.
    Constructor using another path to determine the initial path segments.
    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(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 Type
    Method
    Description
    void
    Reset the path so that it contains no entries.
    double
    curvature(double u)
    Compute the curvature given the 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.
    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
    d2zDu2(double u)
    Get the second derivative of the Z 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.
    double
    dzDu(double u)
    Get the derivative of the Z coordinate with respect to the parameter.
    boolean
    Get the accuracy mode
    boolean
    getBinormal(double u, double[] array)
    Get the binormal vector for a given value of the path parameter.
    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.
    double
    getDistance(double u1, double u2)
    Get the distance traversed on a subpath.
    int
    Get the number of intervals used for cubic splines.
    double
    Get the inversion limit.
    getLocation(double u)
    Get a location for a path parameter;
    double
    Get the maximum value of the 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.
    double
    getZ(double u)
    Get the Z coordinate for a given value of the parameter.
    boolean
    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 the tables used to map the parameter to X, Y, and Z 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.
    double
    torsion(double u)
    Compute the torsion given the path parameter.
    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.Path3D

    append, closePath, getBounds, getCurrentPoint, isEmpty, reset, setupCubic, setupCubic, setupCubic, setupCubic

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public BasicSplinePath3D(Path3D path)
      Constructor using another path to determine the initial path segments.
      Parameters:
      path - the path whose segments will be copied
    • BasicSplinePath3D

      public BasicSplinePath3D(Path3D path, Transform3D transform)
      Constructor using another path to determine the initial path segments, modified with a 3D transform.
      Parameters:
      path - the path whose segments will be copied
      transform - the transform to apply to the path segments
    • BasicSplinePath3D

      public BasicSplinePath3D(Point3D[] pk, int n, boolean closed)
      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 spline
      n - 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(Point3D[] pk, boolean closed)
      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 spline
      closed - true if the spline forms a closed path; false otherwise
    • BasicSplinePath3D

      public 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. 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 path
      pk - the array of points that make up the knots of a spline
      n - 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, Point3D[] pk, boolean closed)
      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 path
      pk - the array of points that make up the knots of a spline
      closed - true if the spline forms a closed path; false otherwise
    • 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 knot
      y - the Y coordinates to use, one for each knot
      z - the Z coordinates to use, one for each knot
      n - 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 knot
      y - the Y coordinates to use, one for each knot
      z - the Z coordinates to use, one for each knot
      closed - 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 path
      x - the X coordinates to use, one for each knot
      y - the Y coordinates to use, one for each knot
      z - the Z coordinates to use, one for each knot
      n - 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 path
      x - the X coordinates to use, one for each knot
      y - the Y coordinates to use, one for each knot
      z - the Z coordinates to use, one for each knot
      closed - 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 of CubicSpline 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 spline specifying the x coordinates to use
      yf - the spline specifying the y coordinates to use
      zf - the spline specifying the y coordinates to use
      closed - 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 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:
      initialCapacity - an estimate for the number of path segments in the path
      xf - the spline specifying the x coordinates to use
      yf - the spline specifying the y coordinates to use
      zf - the spline specifying the y coordinates to use
      closed - true if the spline forms a closed path; false otherwise
      Throws:
      IllegalArgumentException - The spline xf and yf did not have the same number of knots
      IllegalArgumentException - 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 use
      yf - the function specifying the Y coordinates to use
      zf - the function specifying the Z coordinates to use
      t1 - an end point for the domain of the argument of xf and yf
      t2 - the other end point for the domain of the argument of xf and yf
      n - the number of segments between the points at which to evaluate the functions
      closed - 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 path
      xf - the function specifying the X coordinates to use
      yf - the function specifying the Y coordinates to use
      zf - the function specifying the Z coordinates to use
      t1 - an end point for the domain of the argument of xf and yf
      t2 - the other end point for the domain of the argument of xf and yf
      n - the number of segments between the points at which to evaluate the functions
      closed - 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

      public void printTable(Appendable appendable)
      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

      public void printTable(String prefix, Appendable appendable)
      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

      public BasicSplinePath3D.Location getLocation(double u)
      Get a location for a path parameter;
      Parameters:
      u - the path parameter
      Returns:
      the location
    • getX

      public double getX(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • getY

      public double getY(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • getZ

      public double getZ(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • getPoint

      public Point3D getPoint(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • dxDu

      public double dxDu(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • dyDu

      public double dyDu(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • dzDu

      public double dzDu(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • d2xDu2

      public double d2xDu2(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • d2yDu2

      public double d2yDu2(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • d2zDu2

      public double d2zDu2(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - the parameter is out of bounds
    • curvature

      public double curvature(double u) throws IllegalStateException, IllegalArgumentException
      Compute the curvature given the path parameter. The curvature is given by the expression
       sqrt((z"y'-y"z')2 + (x"z'-z"x')2 + (y"x'-x"y')2) / (x'2 + y'2 + z'2)3/2
       
      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.
      Parameters:
      u - the path parameter
      Returns:
      the curvature
      Throws:
      IllegalStateException - the path is not a simple path
      IllegalArgumentException - the parameter is out of bounds
    • torsion

      public double torsion(double u) throws IllegalStateException, IllegalArgumentException
      Compute the torsion given the path parameter. The torsion is given by the expression
      
       (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 )
       
      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.
      Parameters:
      u - the path parameter
      Returns:
      the curvature
      Throws:
      IllegalStateException - the path is not a simple path
      IllegalArgumentException - 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 parameter
      array - 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 parameter
      array - 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 component
      offset - 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 parameter
      array - 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 parameter
      array - 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 parameter
      array - 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 component
      offset - 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 parameter
      array - 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 component
      offset - the array offset
      Returns:
      true if the binormal vector exists; false if the normal vector does not exist
    • dsDu

      public double dsDu(double u) throws IllegalStateException, IllegalArgumentException
      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 path
      IllegalArgumentException - 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 path
      IllegalArgumentException - 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

      public int getSegment(int i, double[] coords) throws IllegalArgumentException
      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 initial PathIterator3D.SEG_MOVETO segment nor a terminating PathIterator3D.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 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 segments
      coords - 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, or PathIterator3D.SEG_CUBICTO)
      Throws:
      IllegalArgumentException
    • getPathLength

      public double getPathLength() throws IllegalStateException, IllegalArgumentException
      Get the total length of the path.
      Returns:
      the path length
      Throws:
      IllegalStateException - the path is not a simple path
      IllegalArgumentException - 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 subpath
      u2 - the parameter at the second end point of a subpath
      Returns:
      the length of the subpath
      Throws:
      IllegalStateException - the path is not a simple path
      IllegalArgumentException - 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 value false 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 subpath
      u2 - 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 path
      IllegalArgumentException - the parameter is out of bounds
    • s

      public double s(double u) throws IllegalStateException, IllegalArgumentException
      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
      IllegalArgumentException
    • u

      public double u(double s) throws IllegalStateException, IllegalArgumentException
      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
      IllegalArgumentException
    • clear

      public void clear()
      Reset the path so that it contains no entries. This method should be used instead of Path3D.reset(), which cannot be overridden due to being declared as final.
    • refresh

      public void refresh() throws IllegalStateException
      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 methods are called, the method refresh() must be called. Paths are modified by calling The method clear() calls Path3D.reset() but also reinitializes the path so that refresh() does not have to be called if segments are added after the call to clear() but before any of the methods in the list starting with getX(double) are called.
      Throws:
      IllegalStateException