public class BSpline extends ParametricCurve
General non-rational B-Spline implementation where the degree can be specified.
For the B-Spline, there are 3 types of knot-vectors, uniform clamped, uniform unclamped, and non-uniform. A uniform knot-vector means that the knots are equally spaced. A clamped knot-vector means that the first k-knots and last k-knots are repeated, where k is the degree + 1. Non-uniform means that the knot-values have no specific properties. For all 3 types, the knot-values must be non-decreasing.
Here are some examples of uniform clamped knot vectors for degree 3:
number of control points = 4: [0, 0, 0, 0, 1, 1, 1, 1] number of control points = 7: [0, 0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1, 1]
The following is a figure of a B-Spline generated using a uniform clamped knot vector:
Here are some examples of uniform unclamped knot vectors for degree 3:
number of control points = 4: [0, 0.14, 0.29, 0.43, 0.57, 0.71, 0.86, 1] (about) number of control points = 7: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
The following is a figure of a B-Spline generated using a uniform unclamped knot vector:
Note: Although the knot-values in the examples are between 0 and 1, this is not a requirement.
When the knot-vector is uniform clamped, the default interval is [0, 1]. When the knot-vector is uniform unclamped, the default interval is [grad * degree, 1 - grad * degree], where grad is the gradient or the knot-span. Specifying the knotVectorType as UNIFORM_CLAMPED or UNIFORM_UNCLAMPED means that the internal knot-vector will not be used.
Note: The computation required is O(2^degree) or exponential. Increasing the degree by 1 means that twice as many computations are done.
Modifier and Type | Field and Description |
---|---|
static int |
NON_UNIFORM |
static int |
UNIFORM_CLAMPED |
static int |
UNIFORM_UNCLAMPED |
Constructor and Description |
---|
BSpline(ControlPath cp,
GroupIterator gi) |
Modifier and Type | Method and Description |
---|---|
void |
appendTo(MultiPath mp)
There are two types of requirements for this curve, common requirements and requirements that depend on the
knotVectorType.
|
protected void |
eval(double[] p)
The eval method evaluates a point on a curve given a parametric value "t".
|
int |
getDegree()
Returns the degree of the curve.
|
ValueVector |
getKnotVector()
Returns the knot-vector for this curve.
|
int |
getKnotVectorType()
Returns the type of knot-vector to use.
|
int |
getSampleLimit()
The sample limit specifies how many additional subdivisions are done to ensure that there
are no missed pieces of the curve.
|
boolean |
getUseDefaultInterval()
Returns the value of the useDefaultInterval flag.
|
protected double |
N(double t,
int i)
Non-recursive implementation of the N-function.
|
void |
resetMemory()
Resets the shared memory to the initial state.
|
void |
setDegree(int d)
Sets the degree of the curve.
|
void |
setInterval(double t_min,
double t_max)
Specifies the interval that the curve should define itself on.
|
void |
setKnotVector(ValueVector v)
Sets the knot-vector for this curve.
|
void |
setKnotVectorType(int type)
Sets the type of knot-vector to use.
|
void |
setSampleLimit(int limit)
Sets the sample-limit.
|
void |
setUseDefaultInterval(boolean b)
Sets the value of the useDefaultInterval flag.
|
double |
t_max()
Returns the finishing interval value.
|
double |
t_min()
Returns the starting interval value.
|
getConnect, getControlPath, getGroupIterator, setConnect, setControlPath, setGroupIterator
public static final int UNIFORM_CLAMPED
public static final int UNIFORM_UNCLAMPED
public static final int NON_UNIFORM
public BSpline(ControlPath cp, GroupIterator gi)
protected void eval(double[] p)
ParametricCurve
eval
in class ParametricCurve
public void setInterval(double t_min, double t_max)
IllegalArgumentException
- If t_min > t_max.t_min()
,
t_max()
public double t_min()
setInterval(double, double)
,
t_max()
public double t_max()
setInterval(double, double)
,
t_min()
public int getSampleLimit()
ParametricCurve
getSampleLimit
in class ParametricCurve
public void setSampleLimit(int limit)
IllegalArgumentException
- If sample-limit < 0.BinaryCurveApproximationAlgorithm
,
getSampleLimit()
public int getDegree()
setDegree(int)
public void setDegree(int d)
IllegalArgumentException
- If degree <= 0.getDegree()
public ValueVector getKnotVector()
setKnotVector(ValueVector)
public void setKnotVector(ValueVector v)
IllegalArgumentException
- If the value-vector is null.getKnotVector()
public boolean getUseDefaultInterval()
setUseDefaultInterval(boolean)
public void setUseDefaultInterval(boolean b)
getUseDefaultInterval()
public int getKnotVectorType()
setKnotVectorType(int)
public void setKnotVectorType(int type)
IllegalArgumentException
- If the knot-vector type is unknown.getKnotVectorType()
public void appendTo(MultiPath mp)
appendTo
in class Curve
MultiPath
,
BinaryCurveApproximationAlgorithm
protected double N(double t, int i)
public void resetMemory()
Curve
resetMemory
in class Curve
Copyright © 2016. All rights reserved.