Class PolylineToCubicCurve

java.lang.Object
org.jhotdraw8.geom.PolylineToCubicCurve

public class PolylineToCubicCurve extends Object
An Algorithm for Automatically Fitting Digitized Curves.

References:

gems/FitCurves.c
An Algorithm for Automatically Fitting Digitized Curves. Graphics Gems, Academic Press. Copyright (c) 1990 Philip J. Schneider.
github.com
Graphics Gems License
  • Method Summary

    Modifier and Type
    Method
    Description
    findCorners(List<javafx.geometry.Point2D> digitizedPoints, double minAngle, double minDistance)
    Finds corners in the provided point list, and returns their indices.
    static void
    fitBezierPath(PathBuilder<?> builder, List<javafx.geometry.Point2D> digitizedPoints, double error)
    Fits a bezier path to the specified list of digitized points.
    static void
    fitBezierPath(PathBuilder<?> builder, javafx.geometry.Point2D[] digitizedPoints, double error)
    Fits a bezier path to the specified list of digitized points.
    static void
    fitBezierPath(PathBuilder<?> builder, BezierPath digitizedPoints, double error)
    Fits a bezier path to the specified list of digitized points.
    static ArrayList<javafx.geometry.Point2D>
    reduceNoise(List<javafx.geometry.Point2D> digitizedPoints, double weight)
    Reduces noise from the digitized points, by applying an approximation of a gaussian filter to the data.
    static ArrayList<javafx.geometry.Point2D>
    removeClosePoints(List<javafx.geometry.Point2D> digitizedPoints, double minDistance)
    Removes points which are closer together than the specified minimal distance.
    static ArrayList<ArrayList<javafx.geometry.Point2D>>
    splitAtCorners(List<javafx.geometry.Point2D> digitizedPoints, double maxAngle, double minDistance)
    Splits the digitized points into multiple segments at each corner point.

    Methods inherited from class java.lang.Object

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

    • fitBezierPath

      public static void fitBezierPath(PathBuilder<?> builder, javafx.geometry.Point2D[] digitizedPoints, double error)
      Fits a bezier path to the specified list of digitized points.

      This is a convenience method for calling fitBezierPath(org.jhotdraw8.geom.PathBuilder<?>, javafx.geometry.Point2D[], double)

      Parameters:
      builder - the builder for the bezier path
      digitizedPoints - digited points.
      error - the maximal allowed error between the bezier path and the digitized points.
    • fitBezierPath

      public static void fitBezierPath(PathBuilder<?> builder, List<javafx.geometry.Point2D> digitizedPoints, double error)
      Fits a bezier path to the specified list of digitized points.
      Parameters:
      builder - the builder for the bezier path
      digitizedPoints - digitized points.
      error - the maximal allowed error between the bezier path and the digitized points.
    • fitBezierPath

      public static void fitBezierPath(PathBuilder<?> builder, BezierPath digitizedPoints, double error)
      Fits a bezier path to the specified list of digitized points.

      This is a convenience method for calling fitBezierPath(org.jhotdraw8.geom.PathBuilder<?>, javafx.geometry.Point2D[], double).

      Parameters:
      builder - the builder for the bezier path
      digitizedPoints - digited points.
      error - the maximal allowed error between the bezier path and the digitized points.
    • removeClosePoints

      public static ArrayList<javafx.geometry.Point2D> removeClosePoints(List<javafx.geometry.Point2D> digitizedPoints, double minDistance)
      Removes points which are closer together than the specified minimal distance.

      The minimal distance should be chosen dependent on the size and resolution of the display device, and on the sampling rate. A good value for mouse input on a display with 100% Zoom factor is 2.

      The purpose of this method, is to remove points, which add no additional information about the shape of the curve from the list of digitized points.

      The cleaned up set of digitized points gives better results, when used as input for method splitAtCorners(java.util.List<javafx.geometry.Point2D>, double, double).

      Parameters:
      digitizedPoints - Digitized points
      minDistance - minimal distance between two points. If minDistance is 0, this method only removes sequences of coincident points.
      Returns:
      Digitized points with a minimal distance.
    • splitAtCorners

      public static ArrayList<ArrayList<javafx.geometry.Point2D>> splitAtCorners(List<javafx.geometry.Point2D> digitizedPoints, double maxAngle, double minDistance)
      Splits the digitized points into multiple segments at each corner point.

      Corner points are both contained as the last point of a segment and the first point of a subsequent segment.

      Parameters:
      digitizedPoints - Digitized points
      maxAngle - maximal angle in radians between the current point and its predecessor and successor up to which the point does not break the digitized list into segments. Recommended value 44° = 44 * 180d / Math.PI
      minDistance - the minimal distance
      Returns:
      Segments of digitized points, each segment having less than maximal angle between points.
    • findCorners

      public static IntArrayList findCorners(List<javafx.geometry.Point2D> digitizedPoints, double minAngle, double minDistance)
      Finds corners in the provided point list, and returns their indices.
      Parameters:
      digitizedPoints - List of digitized points.
      minAngle - Minimal angle for corner points
      minDistance - Minimal distance between a point and adjacent points for corner detection
      Returns:
      list of corner indices.
    • reduceNoise

      public static ArrayList<javafx.geometry.Point2D> reduceNoise(List<javafx.geometry.Point2D> digitizedPoints, double weight)
      Reduces noise from the digitized points, by applying an approximation of a gaussian filter to the data.

      The filter does the following for each point P, with weight 0.5:

      x[i] = 0.5*x[i] + 0.25*x[i-1] + 0.25*x[i+1]; y[i] = 0.5*y[i] + 0.25*y[i-1] + 0.25*y[i+1];

      Parameters:
      digitizedPoints - Digitized points
      weight - Weight of the current point
      Returns:
      Digitized points with reduced noise.