public class BSpline extends Object
Constructor and Description |
---|
BSpline(int degree,
float[] controlPoints,
int[] multiplicities,
boolean throughEndpoints)
Create a spline of the specified degree using the supplied x,y coordinate pairs as the control points.
|
BSpline(int degree,
Vector<SplineControlPoint> controlPoints)
Create e new B-spline of the specified degree using the supplied control points
|
Modifier and Type | Method and Description |
---|---|
static void |
drawSpline(Canvas canvas,
int degree,
float[] controlPoints,
int[] multiplicities,
boolean throughEndpoints,
float tolerance,
Paint paint)
An extension method that supports the drawing of a B-spline.
|
Vector<RealPoint> |
getCurvePoints(float tolerance)
Get a set of points on the spline curve, where the maximum distance between two adjacent points is given by tolerance.
|
String |
toString() |
public BSpline(int degree, Vector<SplineControlPoint> controlPoints)
degree
- Degree of the spline polynomial piecescontrolPoints
- The set of control points used to define the splinepublic BSpline(int degree, float[] controlPoints, int[] multiplicities, boolean throughEndpoints)
degree
- The degree of the underlying piecewise-polynomial segmentscontrolPoints
- The control points used to define the shape of the spline, {x1, y1, x2, y2, ..., xn, yn}multiplicities
- Array giving the multiplicity of each of the control points. The size of the multiplicities
must be half the size of the controlPoints array.throughEndpoints
- Set true to force the spline curve to pass through the end control points. This is accomplished
by forcing the multiplicity of the first and last control points to degree + 1. Note that this
will give a different spline curve than that typically referred to as a "clamped" spline, in
which the spline knots are repeated at the beginning and end to force the spline to pass through
these points. The repeated control-point approach has the advantage of having the "open" spline
(where throughEndpoints is false) being a subset of the "closed" curve; this is not true for
"unclamped" and "clamped" splines.public static void drawSpline(Canvas canvas, int degree, float[] controlPoints, int[] multiplicities, boolean throughEndpoints, float tolerance, Paint paint)
degree
- The degree of the spline; must be > 0controlPoints
- The control points that define the shape of the spline, {x1, y1, x2, y2, ..., xn, yn}.multiplicities
- The multiplicities for the control points; the number of multiplicity values must equal the
number of control points (i.e., the array size must be half that of the controlPoints array)throughEndpoints
- If true, the spline will be forced to pass through the endpoints by setting the end
control point multiplicities to degree + 1tolerance
- For non-DXF canvas types, the spline is drawn as a set of connected line segments; the tolerance
specifies that maximum lenth of each line segment to control the smoothness of the representation.
Ignored for DXFCanvas, which has a true spline representation.paint
- The Paint object used to draw the splinepublic Vector<RealPoint> getCurvePoints(float tolerance)
tolerance
- The maximum distance between any two adjacent points in the return vector