java.lang.Object
com.marginallyclever.donatello.Bezier

public class Bezier
extends java.lang.Object
4 point cubic bezier splines. Based on pelson/antigrain and mattdesl/adaptive-bezier-curve.
  • Constructor Summary

    Constructors
    Constructor Description
    Bezier​(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
    Default constructor that takes four control points.
  • Method Summary

    Modifier and Type Method Description
    java.util.List<Point2D> generateCurvePoints​(double distanceTolerance)
    Returns a list of points along the curve.
    protected java.util.ArrayList<Point2D> generateCurvePointsOld()
    Returns a list of points along the curve.
    protected double lerp​(double a, double b, double fraction)
    linear interpolation equivalent to

    Methods inherited from class java.lang.Object

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

    • Bezier

      public Bezier​(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
      Default constructor that takes four control points.
      Parameters:
      x0 - control point 1
      y0 - control point 1
      x1 - control point 2
      y1 - control point 2
      x2 - control point 3
      y2 - control point 3
      x3 - control point 4
      y3 - control point 4
  • Method Details

    • generateCurvePoints

      public java.util.List<Point2D> generateCurvePoints​(double distanceTolerance)
      Returns a list of points along the curve. Based on pelson/antigrain and mattdesl/adaptive-bezier-curve.
      Parameters:
      distanceTolerance - the allowed tolerance.
      Returns:
      a list of points along the curve.
    • generateCurvePointsOld

      protected java.util.ArrayList<Point2D> generateCurvePointsOld()
      Returns a list of points along the curve.
      Returns:
      a list of points along the curve.
    • lerp

      protected double lerp​(double a, double b, double fraction)
      linear interpolation equivalent to
      (b-a) * fraction + a
      Parameters:
      a - the starting position
      b - the ending position
      fraction - some value assumed to be between 0....1, inclusive.
      Returns:
      the interpolated position.