Class Path3DInfo

java.lang.Object
org.bzdev.geom.Path3DInfo

public class Path3DInfo extends Object
Class providing static methods to obtain information about paths defined by java.awt.geom.Path3D.

The method shiftClosedPath(Path3D,double,double,double) returns a modified path (the same path as its argument but with its starting point shifted). The class PathSplitter will allow various paths to be constructed.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Class defining a list entry describing a path segment.
    static final class 
    Class to store values used in computations on a segment of a path.
    static final class 
    Class to represent a value of the path parameter u.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    cubicLength(double u, double x0, double y0, double z0, double[] coords)
    Compute the length of a cubic path segment from its start to a position specified by the path parameter
    cubicLengthFunction(double x0, double y0, double z0, double[] coords)
    Compute a function that provides the length of a cubic path segment from its start to a position specified by the path parameter.
    static double
    curvature(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the curvature given path-segment parameters.
    boolean
    curvatureExists(double u, double x0, double y0, double z0, int type, double[] coords)
    Determine if the arguments allow the curvature to be computed.
    static double
    d2sDu2(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the second derivative of the path length s with respect to u given path-segment parameters.
    static double
    d2xDu2(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the second derivative of x with respect to u given path-segment parameters.
    static double
    d2yDu2(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the second derivative of y with respect to u given path-segment parameters.
    static double
    d2zDu2(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the second derivative of z with respect to u given path-segment parameters.
    static double
    d3xDu3(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the third derivative of x with respect to u given path-segment parameters.
    static double
    d3yDu3(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the third derivative of y with respect to u given path-segment parameters.
    static double
    d3zDu3(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the third derivative of z with respect to u given path-segment parameters.
    static double
    dsDu(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the derivative of the path length s with respect to the path's parameter u given path-segment parameters.
    static double
    dxDu(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute dx/du given path-segment parameters.
    static double
    dyDu(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute dy/du given path-segment parameters.
    static double
    dzDu(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute dz/du given path-segment parameters.
    static void
    elevateDegree(int degree, double[] result, double x, double y, double z, double[] coords)
    Elevate the degree of a three-dimensional Bézier curve of degree n by 1, specifying the last n control points in an array.
    static void
    elevateDegree(int degree, double[] result, int rOffset, double[] coords, int cOffset)
    Elevate the degree of a three-dimensional Bézier curve by 1.
    static boolean
    getBinormal(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
    Get the binormal vector for a given value of the path parameter and an offset for the array storing the normal vector.
    static double[]
    getControlPoints(Path3D path, boolean all)
    List the control points of a path.
    static double[]
    getControlPoints(PathIterator3D pit, boolean all)
    List the control points of a path provided by a path iterator
    Get a list of entries describing a path's segments or those for the outline of a shape.
    Get a list of entries describing a path's segments or those for the outline of a shape, modified by an affine transform.
    static boolean
    getFirstTNB(Path3D path, double[] tangent, double[] normal, double[] binormal)
    Get the tangent vector, normal vector, and binormal vector of the first point along a path where all three exist.
    static boolean
    getNormal(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
    Get the normal vector for a given value of the path parameter and an offset for the array storing the normal vector.
    Get a 3D path iterator for the path implied by three cubic splines.
    static boolean
    getStartingTangent(Path3D path, double[] tangent)
    Get the first point on the first segment of a path where a tangent vector exists.
    static boolean
    getTangent(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
    Get the tangent vector for a specified value of the path parameter and an output-array offset.
    static String
    getTypeString(int type)
    Get the type of a path-iterator item, formatted as a string
    static double
    getX(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the x coordinate of a point on the path given path-segment parameters.
    static double
    getY(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the y coordinate of a point on a path given path-segment parameters.
    static double
    getZ(double u, double x0, double y0, double z0, int type, double[] coords)
    Compute the z coordinate of a point on a path given path-segment parameters.
    static boolean
    Determine if the first continuous portion of a path is closed.
    static int
    Count the number of segments in the first continuous portion of a path that are Drawable.
    static double
    Compute the length of a path or the length of an outline of a shape.
    static double
    pathLength(Path3D path, int start, int end)
    Compute the length of a path or the length of an outline of a shape for a given range of path/outline segments.
    static double
    Compute the length of a path or the length of an outline of a shape, modified by an affine transform.
    static double
    pathLength(Path3D path, Transform3D at, int start, int end)
    Compute the length of a path or the length of an outline of a shape for a given range of path/outline segments, modified by an affine transform.
    static void
    Print information about the segments that make up a path or an outline of a shape.
    static void
    printSegments(String prefix, Appendable appendable, Path3D s)
    Print information about the segments that make up a path or the outline of a shape, adding a prefix.
    static void
    Print information about the segments that make up a path, or the outline of a shape, to the standard output.
    static double
    quadLength(double u, double x0, double y0, double z0, double[] coords)
    Compute the length of a quadratic path segment from its start to a position specified by the path parameter.
    quadLengthFunction(double x0, double y0, double z0, double[] coords)
    Provide a function that computes the length of a quadratic path segment from its start to a position specified by a path parameter.
    static double
    segmentLength(double u, int type, double x0, double y0, double z0, double[] coords)
    Get the length of a subpath of a path segment.
    static double
    segmentLength(int type, double x0, double y0, double z0, double[] coords)
    Compute the length of a segment given parameters describing it.
    static double
    segmentLength(Path3D p, int segment)
    Get the length of the ith segment of a path or of a shape's outline.
    segmentLengthFunction(int type, double x0, double y0, double z0, double[] coords)
    Provide a function to compute the length of a subpath of a path segment.
    static Path3D
    shiftClosedPath(Path3D path, double x, double y, double z)
    Find the first closed component of a path that goes through a point (x, y, z) and shift that path component so it starts at (x, y, z); The point (x, y, z) must be the last point in a segment (including a MOVE_TO segment).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • segmentLength

      public static double segmentLength(double u, int type, double x0, double y0, double z0, double[] coords) throws IllegalArgumentException
      Get the length of a subpath of a path segment.

      When the path parameter is PathIterator3D.SEG_CLOSE, the array must contain the X, Y, and Z coordinates of the path's initial point in that order.

      Parameters:
      u - the path parameter for the end of the subpath which includes all points on the path whose path parameters are in the range [0, u]
      type - either PathIterator3D.SEG_MOVETO PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO, or PathIterator3D.SEG_CLOSE
      x0 - the X coordinate at the start of the segment
      y0 - the Y cooredinate at the start of the segment
      z0 - the X cooredinate at the start of the segment
      coords - the remaining control points, with the X coordinate followed immediately by the Y coordinate and then the Z coordinate for each
      Returns:
      the path-sgement length
      Throws:
      IllegalArgumentException - if the type argument is not recognized or if the fifth argument is null or is too short
    • segmentLengthFunction

      public static RealValuedFunctOps segmentLengthFunction(int type, double x0, double y0, double z0, double[] coords) throws IllegalArgumentException, ArithmeticException
      Provide a function to compute the length of a subpath of a path segment.

      When the path parameter is PathIterator3D.SEG_CLOSE, the array must contain the X, Y, and Z coordinates of the path's initial point in that order.

      Parameters:
      type - either PathIterator3D.SEG_MOVETO PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO, or PathIterator3D.SEG_CLOSE
      x0 - the X coordinate at the start of the segment
      y0 - the Y cooredinate at the start of the segment
      z0 - the X cooredinate at the start of the segment
      coords - the remaining control points, with the X coordinate followed immediately by the Y coordinate and then the Z coordinate for each
      Returns:
      a function that will compute the length of a subsegment of a path segement from the segment's start to the point specified by a path parameter provided as the function's argument
      Throws:
      IllegalArgumentException - if the type argument is not recognized or if the fifth argument is null or is too short
      ArithmeticException - if a real-valued function could not be provided
    • quadLength

      public static double quadLength(double u, double x0, double y0, double z0, double[] coords)
      Compute the length of a quadratic path segment from its start to a position specified by the path parameter.
      Parameters:
      u - the path parameter in the range [0.0, 1.0]
      x0 - the X coordinate of the first control point
      y0 - the Y coordinate of the first control point
      z0 - the Z coordinate of the first control point
      coords - the remaining control points in order, with each control point represented by 3 consecutive elements contining a control point's X coordinate, Y coordinate, and Z coordinate respectively (only the first 6 indices will be used)
      Returns:
      the path length from u = 0 to the given value of u.
    • quadLengthFunction

      public static RealValuedFunctOps quadLengthFunction(double x0, double y0, double z0, double[] coords)
      Provide a function that computes the length of a quadratic path segment from its start to a position specified by a path parameter.
      Parameters:
      x0 - the X coordinate of the first control point
      y0 - the Y coordinate of the first control point
      z0 - the Z coordinate of the first control point
      coords - the remaining control points in order, with each control point represented by 3 consecutive elements contining a control point's X coordinate, Y coordinate, and Z coordinate respectively (only the first 6 indices will be used)
      Returns:
      a function of the path parameter providing the length of a path segment from its start to the point specified by the path parameter provided as the function's argument
    • cubicLength

      public static double cubicLength(double u, double x0, double y0, double z0, double[] coords)
      Compute the length of a cubic path segment from its start to a position specified by the path parameter
      Parameters:
      u - the path parameter in the range [0.0, 1.0]
      x0 - the X coordinate of the first control point
      y0 - the Y coordinate of the first control point
      z0 - the Z coordinate of the first control point
      coords - the remaining control points in order, with each control point represented by 3 consecutive elements contining a control point's X coordinate, Y coordinate, and Z coordinate respectively (only the first 9 indices will be used)
      Returns:
      the path length from u = 0 to the given value of u.
    • cubicLengthFunction

      public static RealValuedFunctOps cubicLengthFunction(double x0, double y0, double z0, double[] coords)
      Compute a function that provides the length of a cubic path segment from its start to a position specified by the path parameter.
      Parameters:
      x0 - the X coordinate of the first control point
      y0 - the Y coordinate of the first control point
      z0 - the Z coordinate of the first control point
      coords - the remaining control points in order, with each control point represented by 3 consecutive elements contining a control point's X coordinate, Y coordinate, and Z coordinate respectively (only the first 9 indices will be used)
      Returns:
      a function of the path parameter that computes the length of a path segment from its start to the point corresponding to the path parameter provided as the function's argument
    • getControlPoints

      public static double[] getControlPoints(Path3D path, boolean all)
      List the control points of a path.
      Parameters:
      path - the path
      all - true if all control points are included; false if only the control points starting or ending a segment are included
      Returns:
      an array containing the countrol points, each as a triplet of values where each triplet consists of a control point's X coordinate, followed by its Y coordinate, followed by its Z coordinate
    • getControlPoints

      public static double[] getControlPoints(PathIterator3D pit, boolean all)
      List the control points of a path provided by a path iterator
      Parameters:
      pit - the path iterator providing the control points
      all - true if all control points are included; false if only the control points starting or ending a segment are included
      Returns:
      an array containing the countrol points, each as a triplet of values where each triplet consists of a control point's X coordinate, followed by its Y coordinate, followed by its Z coordinate
    • getPathIterator

      public static PathIterator3D getPathIterator(AffineTransform3D af, CubicSpline x, CubicSpline y, CubicSpline z)
      Get a 3D path iterator for the path implied by three cubic splines. The splines must have the same number of knots.
      Parameters:
      af - the affine transform to apply to the path iterator; null is equivalent to an identity transform
      x - the cubic spline for the X coordinates
      y - the cubic spline for the Y coordinates
      z - the cubic spline for the Z coordinates
      Returns:
      the path iterator
    • elevateDegree

      public static void elevateDegree(int degree, double[] result, int rOffset, double[] coords, int cOffset)
      Elevate the degree of a three-dimensional Bézier curve by 1. The algorithm is describe in Degree Elevation of a Bézier Curve. The length of the coords array must be at least 3*(degree+1), whereas the length of the result array must be at least 3*(degree+2).

      Control points are stored so that the x, y, and z coordinates for control point i/3 are in array locations i, i+1, and i+2 where i = 0 (mod 3).

      Parameters:
      degree - the degree of the original curve
      result - an array storing the control points for an the new curve
      rOffset - the offset into the result array at which the control points for the new curve will be stored
      coords - the array containing the control points for the original curve
      cOffset - the offset into the coords array at which the control points for the original curve start
    • elevateDegree

      public static void elevateDegree(int degree, double[] result, double x, double y, double z, double[] coords)
      Elevate the degree of a three-dimensional Bézier curve of degree n by 1, specifying the last n control points in an array. The length of the result array must be at least 3*(n+1), whereas the length of the coords array must be at least 3*n. The algorithm is describe in Degree Elevation of a Bézier Curve.

      Control points are stored so that the x, y, and z coordinates for control point (i/3)+1 are in array locations i, i+1, and i+2 respectively, where i = 0 (mod 3).

      Parameters:
      degree - the degree of the curve
      result - an array storing the last n control points for an the new curve, which excludes its starting point
      x - the X coordinate for the start of the curve (control point 0)
      y - the Y coordinate for the start of the curve (control point 0)
      z - the Z coordinate for the start of the curve (control point 0)
      coords - the array containing the last n-1 control points for the original curve, which excludes its starting point
    • getX

      public static double getX(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the x coordinate of a point on the path given path-segment parameters. When the type is SEG_MOVETO, x0 and y0 are ignored. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO, and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of the x coordinate
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • getY

      public static double getY(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the y coordinate of a point on a path given path-segment parameters. When the type is SEG_MOVETO, x0 and y0 are ignored. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of the y coordinate
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • getZ

      public static double getZ(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the z coordinate of a point on a path given path-segment parameters. When the type is SEG_MOVETO, x0 and y0 are ignored. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of the y coordinate
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • dxDu

      public static double dxDu(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute dx/du given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of dx/ds
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • dyDu

      public static double dyDu(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute dy/du given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of dy/du
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • dzDu

      public static double dzDu(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute dz/du given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0;
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of dy/du
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • dsDu

      public static double dsDu(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the derivative of the path length s with respect to the path's parameter u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of ds/du
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d2xDu2

      public static double d2xDu2(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the second derivative of x with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2x/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d2yDu2

      public static double d2yDu2(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the second derivative of y with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2y/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d2zDu2

      public static double d2zDu2(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the second derivative of z with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2y/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d3xDu3

      public static double d3xDu3(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the third derivative of x with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.

      Note: the value is 0.0 except for a cubic segment, where it is constant for u in the range [0.0, 1.0]. Curves with torsion should be represented by cubic Bézier curves for accuracy.

      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2x/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d3yDu3

      public static double d3yDu3(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the third derivative of y with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.

      Note: the value is 0.0 except for a cubic segment, where it is constant for u in the range [0.0, 1.0]. Curves with torsion should be represented by cubic Bézier curves for accuracy.

      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2y/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d3zDu3

      public static double d3zDu3(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the third derivative of z with respect to u given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.

      Note: the value is 0.0 except for a cubic segment, where it is constant for u in the range [0.0, 1.0]. Curves with torsion should be represented by cubic Bézier curves for accuracy.

      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2y/du2;
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • d2sDu2

      public static double d2sDu2(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the second derivative of the path length s with respect to u given path-segment parameters. When the type is SEG_CLOSE, the first two elements of the fifth argument (coords) must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO.

      The returned value will be Double.NaN in cases where division by zero would occur, such as when the initial point for a segment and the control points and final point given by the array argument are identical. The most likely case is when the type is PathIterator3D.SEG_CLOSE.

      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the value of d2s/du2; Double.NaN if not defined but zero if the type is PathIterator3D.SEG_MOVETO
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
      See Also:
    • curvature

      public static double curvature(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException
      Compute the curvature given path-segment parameters. The type may not be SEG_MOVETO. When the type is SEG_CLOSE, the first two elements of coords must be set to the x and y coordinate respectively for the point provided by most recent segment whose type is SET_MOVETO. 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-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the curvature; Double.NaN if not defined (this may happen if a line segment has zero length)
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      ArrayIndexOutOfBoundsException - the array argument was two small
      NullPointerException - the array argument was null
    • curvatureExists

      public boolean curvatureExists(double u, double x0, double y0, double z0, int type, double[] coords) throws IllegalArgumentException, NullPointerException, IndexOutOfBoundsException
      Determine if the arguments allow the curvature to be computed. The curvature cannot be computed when the type is PathIterator3D.SEG_MOVETO or when the control points provided by the array match the initial values x0 and y0.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the curvature; Double.NaN if not defined (this may happen if a line segment has zero length)
      Throws:
      IllegalArgumentException - u is out of range or the type does not have a legal value
      NullPointerException
      IndexOutOfBoundsException
    • getTangent

      public static boolean getTangent(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
      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-segment parameter in the range [0,1]
      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 and array[offset+1] containing the tangent vector's Y component
      offset - the index into the array at which to store the tangent vector
      x0 - the X coordinate of the point on the segment for u = 0
      y0 - the Y coordinate of the point on the segment for u = 0
      z0 - the Z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the X and Y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      true if the tangent vector exists; false if the tangent vector does not exist
    • getNormal

      public static boolean getNormal(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
      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 not be changed.
      Parameters:
      u - the path-segment parameter in the range [0,1]
      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, array[offset+1] containing the normal vector's Y component, and array[offset + 2] containing the normal vector's Y component
      offset - the index into the array at which to store the normal vector
      x0 - the X coordinate of the point on the segment for u = 0
      y0 - the Y coordinate of the point on the segment for u = 0
      z0 - the Y coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO, and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator3D, but with coords[0], coords[1], and coords[2] set to the X, Y, and Z coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      true if the normal vector exists; false if the normal vector does not exist
    • getBinormal

      public static boolean getBinormal(double u, double[] array, int offset, double x0, double y0, double z0, int type, double[] coords)
      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 × N of the tangent vector T and the normal vector N. 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-segment parameter in the range [0,1]
      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, array[offset+1] containing the normal vector's Y component, and array[offset + 2] containing the normal vector's Y component
      offset - the index into the array at which to store the normal vector
      x0 - the X coordinate of the point on the segment for u = 0
      y0 - the Y coordinate of the point on the segment for u = 0
      z0 - the Y coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO, and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator3D, but with coords[0], coords[1], and coords[2] set to the X, Y, and Z coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      true if the normal vector exists; false if the normal vector does not exist
    • getTypeString

      public static String getTypeString(int type)
      Get the type of a path-iterator item, formatted as a string
      Parameters:
      type - the path-iterator type as an integer
      Returns:
      a string describing the type
    • pathLength

      public static double pathLength(Path3D path)
      Compute the length of a path or the length of an outline of a shape. This is the sum of the the lengths of all the path or outline segments. A shape's outline may pass through the shape, so this method does not reliably compute the circumference of a shape.
      Parameters:
      path - the path
      Returns:
      the path length
    • pathLength

      public static double pathLength(Path3D path, Transform3D at)
      Compute the length of a path or the length of an outline of a shape, modified by an affine transform. This is the sum of the the lengths of all the path or outline segments. A shape's outline may pass through the shape, so this method does not reliably compute the circumference of a shape.
      Parameters:
      path - the path
      at - the affine transform; null if none is to be used
      Returns:
      the path length
    • pathLength

      public static double pathLength(Path3D path, int start, int end)
      Compute the length of a path or the length of an outline of a shape for a given range of path/outline segments. This is the sum of the the lengths of all the path segments whose indices are in the interval [start, end) with start < end. Some of the segments for a shape may pass though the interior of the shape.
      Parameters:
      path - the path
      start - the starting index
      end - the index just past the last index counted
      Returns:
      the length of the portion of a path in the specified interval
    • pathLength

      public static double pathLength(Path3D path, Transform3D at, int start, int end)
      Compute the length of a path or the length of an outline of a shape for a given range of path/outline segments, modified by an affine transform. This is the sum of the the lengths of all the path segments whose indices are in the interval [start, end) with start < end. Some of the segments for a shape may pass though the interior of the shape.
      Parameters:
      path - the path
      at - the affine transform; null if none is to be used
      start - the starting index
      end - the index just past the last index counted
      Returns:
      the length of the portion of a path in the specified interval
    • segmentLength

      public static double segmentLength(int type, double x0, double y0, double z0, double[] coords)
      Compute the length of a segment given parameters describing it.
      Parameters:
      x0 - the x coordinate of the point on the segment for u = 0
      y0 - the y coordinate of the point on the segment for u = 0
      z0 - the z coordinate of the point on the segment for u = 0
      type - the segment type as defined by PathIterator3D (values may be PathIterator3D.SEG_MOVETO, PathIterator3D.SEG_LINETO, PathIterator3D.SEG_QUADTO, PathIterator3D.SEG_CUBICTO and PathIterator3D.SEG_CLOSE)
      coords - the coordinates array as defined by PathIterator, but with coords[0] and coords[1] set to the x and y coordinates respectively for the last MOVETO operation when the type is PathIterator3D.SEG_CLOSE
      Returns:
      the segment length
    • segmentLength

      public static double segmentLength(Path3D p, int segment)
      Get the length of the ith segment of a path or of a shape's outline. For a shape, some of the segments may pass through the interior of the shape.
      Parameters:
      p - the path or shape
      segment - the segment number from 0 up to but not including the number of segments
      Returns:
      the segment length
    • getEntries

      public static List<Path3DInfo.Entry> getEntries(Path3D p)
      Get a list of entries describing a path's segments or those for the outline of a shape.
      Parameters:
      p - the path or shape
      Returns:
      the list of entries
    • getEntries

      public static List<Path3DInfo.Entry> getEntries(Path3D p, Transform3D at)
      Get a list of entries describing a path's segments or those for the outline of a shape, modified by an affine transform.
      Parameters:
      p - the path or shape
      at - the affine transform; null if none is to be used
      Returns:
      the list of entries
    • printSegments

      public static void printSegments(Path3D s)
      Print information about the segments that make up a path, or the outline of a shape, 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.
      Parameters:
      s - the shape or path
    • printSegments

      public static void printSegments(Appendable appendable, Path3D s)
      Print information about the segments that make up a path or an outline of a shape. 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.
      Parameters:
      appendable - an Appendable on which to print
      s - the shape or path
    • printSegments

      public static void printSegments(String prefix, Appendable appendable, Path3D s)
      Print information about the segments that make up a path or the outline of a shape, 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.
      Parameters:
      prefix - a prefix to print at the start of each line (null implies an empty string)
      appendable - the appendable for output
      s - the shape or path
    • shiftClosedPath

      public static Path3D shiftClosedPath(Path3D path, double x, double y, double z)
      Find the first closed component of a path that goes through a point (x, y, z) and shift that path component so it starts at (x, y, z); The point (x, y, z) must be the last point in a segment (including a MOVE_TO segment).
      Parameters:
      path - the path
      x - the X coordinate of a point on the path
      y - the Y coordinate of a point on the path
      z - the Z coordinate of a point on the path
      Returns:
      the patch component going through (x, y, z), with its segments shifted cyclically so that the returned path starts at the point (x, y, z).
      Throws:
      IllegalArgumentException - an argument was illegal
    • numberOfDrawableSegments

      public static int numberOfDrawableSegments(Path3D path)
      Count the number of segments in the first continuous portion of a path that are Drawable. Drawable segments exclude PathIterator3D.SEG_MOVETO segments and PathIterator3D.SEG_CLOSE segments whose current point is the same as that of a previous PathIterator3D.SEG_MOVETO segment. The test ignores any segments after a second PathIterator3D.SEG_MOVE, excluding an initial set of back-to-back PathIterator3D.SEG_MOVE segments, or a first PathIterator3D.SEG_CLOSE. If the last point is the segment preceding a PathIterator3D.SEG_CLOSE segment is equal to t he initial segment (whose type is first PathIterator3D.SEG_MOVETO), the terminating PathIterator3D.SEG_CLOSE segment is not included in the count.
      Parameters:
      path - the path
      Returns:
      true if the path is closed; false otherwise
      Throws:
      IllegalStateException - if the path does not start with a segment whose type is PathIterator3D.SEG_MOVE.
    • isClosed

      public static boolean isClosed(Path3D path)
      Determine if the first continuous portion of a path is closed. The test ignores any segments
      Parameters:
      path - the path
      Returns:
      true if the path is closed; false otherwise
    • getFirstTNB

      public static boolean getFirstTNB(Path3D path, double[] tangent, double[] normal, double[] binormal)
      Get the tangent vector, normal vector, and binormal vector of the first point along a path where all three exist.

      A path can be represented as a function P(s) that specifies a point as a function of the distance along a path. The tangent vector T = dP/ds points in the direction of an increasing path parameter. The normal vector is perpendicular to the tangent vector and is equal to (1/κ)(dT/ds) where s is the distance along the path. The binormal vector B is equal to the cross product T × N. All are unit vectors. Because dT/ds and κ, are zero for a straight-line segment, these segments do not have a unique normal vector. As a result, initial straight-line segments are skipped

      A precondition is that the path must be such that its tangent vector is a continuous function of the path parameter, and the tangent function should be a differentiable function as well, which implies that successive straight-line segments should have the same tangent vectors.

      Parameters:
      path - the path
      tangent - the tangent vector; null if not wanted
      normal - the normal vector; null if not wanted
      binormal - the binormal vector; null if not wanted
      Returns:
      true on success; false on failure
    • getStartingTangent

      public static boolean getStartingTangent(Path3D path, double[] tangent)
      Get the first point on the first segment of a path where a tangent vector exists. If the path consists of multiple disjoint components, only the first component is used.
      Parameters:
      path - the path
      tangent - the tangent, stored in x, y, z order
      Returns:
      true if a tangent exists; false otherwise