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 toMethods 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 1y0
- control point 1x1
- control point 2y1
- control point 2x2
- control point 3y2
- control point 3x3
- control point 4y3
- control point 4
-
-
Method Details
-
generateCurvePoints
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
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 positionb
- the ending positionfraction
- some value assumed to be between 0....1, inclusive.- Returns:
- the interpolated position.
-