CurveSmoothing
edu.rit.numeric

Class CurveSmoothing



  • public class CurveSmoothingextends Object
    Class CurveSmoothing provides operations useful for creating smooth cubic spline curves.

    We are given a sequence of n coordinate values, u[0] .. u[n-1]. These may be either the X coordinates or the Y coordinates of a sequence of 2-D points. We wish to join successive pairs of points with a sequence of cubic Bezier curves to create an overall cubic spline curve. We need to know the X or Y coordinates of the two Bezier control points for each Bezier curve. The Bezier control point coordinates are designated by a[i] and c[i], such that Bezier curve i is defined by u[i], a[i], c[i], and u[i+1] in that order.

    There are several cases:

    1. The curve is closed (there is a Bezier curve from point n-1 back to point 0). We need the n Bezier control points a[0] .. a[n-1] and the n Bezier control points c[0] .. c[n-1]. The first Bezier curve will be u[0]--a[0]--c[0]--u[1], and the last Bezier curve will be u[n-1]--a[n-1]--c[n-1]--u[0].
       
    2. The curve is open (there is no Bezier curve from point n-1 back to point 0). We need the n-1 Bezier control points a[0] .. a[n-2] and the n-1 Bezier control points c[0] .. c[n-2]. The first Bezier curve will be u[0]--a[0]--c[0]--u[1], and the last Bezier curve will be u[n-2]--a[n-2]--c[n-2]--u[n-1].

      For the initial point u[0], an additional condition must be specified, either:

      1. Zero curvature at the initial point; or
      2. Initial direction, specified as a straight line from a coordinate uInitial to u[0].

      For the final point u[n-1], an additional condition must be specified, either:

      1. Zero curvature at the final point; or
      2. Final direction, specified as a straight line from u[n-1] to a coordinate uFinal.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      static voidcomputeBezierClosed(double[] u, double[] a, double[] c, int i, int n)
      Compute the Bezier control point coordinates for a closed smooth curve.
      static voidcomputeBezierOpen(double[] u, double[] a, double[] c, int i, int n)
      Compute the Bezier control point coordinates for an open smooth curve with zero initial curvature and zero final curvature.
      static voidcomputeBezierOpen(double[] u, double uFinal, double[] a, double[] c, int i, int n)
      Compute the Bezier control point coordinates for an open smooth curve with zero initial curvature and a specified final direction.
      static voidcomputeBezierOpen(double uInitial, double[] u, double[] a, double[] c, int i, int n)
      Compute the Bezier control point coordinates for an open smooth curve with a specified initial direction and zero final curvature.
      static voidcomputeBezierOpen(double uInitial, double[] u, double uFinal, double[] a, double[] c, int i, int n)
      Compute the Bezier control point coordinates for an open smooth curve with a specified initial direction and a specified final direction.
    • Method Detail

      • computeBezierClosed

        public static void computeBezierClosed(double[] u,                       double[] a,                       double[] c,                       int i,                       int n)
        Compute the Bezier control point coordinates for a closed smooth curve.
        Parameters:
        u - An input array of coordinates. Elements at indexes i .. i+n-1 are used.
        a - An output array of coordinates for the first Bezier control points. Elements at indexes i .. i+n-1 are used.
        c - An output array of coordinates for the second Bezier control points. Elements at indexes i .. i+n-1 are used.
        i - Index of first element used in input and output arrays.
        n - Number of elements used in input and output arrays. Must be greater than or equal to 3.
        Throws:
        IllegalArgumentException - (unchecked exception) Thrown if n < 3.
        DomainException - (unchecked exception) Thrown if the control points cannot be calculated.
      • computeBezierOpen

        public static void computeBezierOpen(double[] u,                     double[] a,                     double[] c,                     int i,                     int n)
        Compute the Bezier control point coordinates for an open smooth curve with zero initial curvature and zero final curvature.
        Parameters:
        u - An input array of coordinates. Elements at indexes i .. i+n-1 are used.
        a - An output array of coordinates for the first Bezier control points. Elements at indexes i .. i+n-2 are used.
        c - An output array of coordinates for the second Bezier control points. Elements at indexes i .. i+n-2 are used.
        i - Index of first element used in input and output arrays.
        n - Number of elements used in input array; one fewer elements used in output arrays. Must be greater than or equal to 3.
        Throws:
        IllegalArgumentException - (unchecked exception) Thrown if n < 3.
        DomainException - (unchecked exception) Thrown if the control points cannot be calculated.
      • computeBezierOpen

        public static void computeBezierOpen(double uInitial,                     double[] u,                     double[] a,                     double[] c,                     int i,                     int n)
        Compute the Bezier control point coordinates for an open smooth curve with a specified initial direction and zero final curvature.
        Parameters:
        uInitial - Specifies initial direction as a straight line from uInitial to u[i].
        u - An input array of coordinates. Elements at indexes i .. i+n-1 are used.
        a - An output array of coordinates for the first Bezier control points. Elements at indexes i .. i+n-2 are used.
        c - An output array of coordinates for the second Bezier control points. Elements at indexes i .. i+n-2 are used.
        i - Index of first element used in input and output arrays.
        n - Number of elements used in input array; one fewer elements used in output arrays. Must be greater than or equal to 2.
        Throws:
        IllegalArgumentException - (unchecked exception) Thrown if n < 2.
        DomainException - (unchecked exception) Thrown if the control points cannot be calculated.
      • computeBezierOpen

        public static void computeBezierOpen(double[] u,                     double uFinal,                     double[] a,                     double[] c,                     int i,                     int n)
        Compute the Bezier control point coordinates for an open smooth curve with zero initial curvature and a specified final direction.
        Parameters:
        u - An input array of coordinates. Elements at indexes i .. i+n-1 are used.
        uFinal - Specifies final direction as a straight line from u[i+n-1] to uFinal.
        a - An output array of coordinates for the first Bezier control points. Elements at indexes i .. i+n-2 are used.
        c - An output array of coordinates for the second Bezier control points. Elements at indexes i .. i+n-2 are used.
        i - Index of first element used in input and output arrays.
        n - Number of elements used in input array; one fewer elements used in output arrays. Must be greater than or equal to 2.
        Throws:
        IllegalArgumentException - (unchecked exception) Thrown if n < 2.
        DomainException - (unchecked exception) Thrown if the control points cannot be calculated.
      • computeBezierOpen

        public static void computeBezierOpen(double uInitial,                     double[] u,                     double uFinal,                     double[] a,                     double[] c,                     int i,                     int n)                              throws DomainException
        Compute the Bezier control point coordinates for an open smooth curve with a specified initial direction and a specified final direction.
        Parameters:
        uInitial - Specifies initial direction as a straight line from uInitial to u[i].
        u - An input array of coordinates. Elements at indexes i .. i+n-1 are used.
        uFinal - Specifies final direction as a straight line from u[i+n-1] to uFinal.
        a - An output array of coordinates for the first Bezier control points. Elements at indexes i .. i+n-2 are used.
        c - An output array of coordinates for the second Bezier control points. Elements at indexes i .. i+n-2 are used.
        i - Index of first element used in input and output arrays.
        n - Number of elements used in input array; one fewer elements used in output arrays. Must be greater than or equal to 2.
        Throws:
        IllegalArgumentException - (unchecked exception) Thrown if n < 2.
        DomainException - (unchecked exception) Thrown if the control points cannot be calculated.

SCaVis 2.1 © jWork.ORG