Class BSpline
- Direct Known Subclasses:
NURBSpline
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThere are two types of requirements for this curve, common requirements and requirements that depend on the knotVectorType.protected voideval(double[] p) The eval method evaluates a point on a curve given a parametric value "t".intReturns the degree of the curve.Returns the knot-vector for this curve.intReturns the type of knot-vector to use.intThe sample limit specifies how many additional subdivisions are done to ensure that there are no missed pieces of the curve.booleanReturns the value of the useDefaultInterval flag.protected doubleN(double t, int i) Non-recursive implementation of the N-function.voidResets the shared memory to the initial state.voidsetDegree(int d) Sets the degree of the curve.voidsetInterval(double t_min, double t_max) Specifies the interval that the curve should define itself on.voidSets the knot-vector for this curve.voidsetKnotVectorType(int type) Sets the type of knot-vector to use.voidsetSampleLimit(int limit) Sets the sample-limit.voidsetUseDefaultInterval(boolean b) Sets the value of the useDefaultInterval flag.doublet_max()Returns the finishing interval value.doublet_min()Returns the starting interval value.Methods inherited from class com.graphbuilder.curve.Curve
getConnect, getControlPath, getGroupIterator, setConnect, setControlPath, setGroupIterator
-
Field Details
-
UNIFORM_CLAMPED
public static final int UNIFORM_CLAMPED- See Also:
-
UNIFORM_UNCLAMPED
public static final int UNIFORM_UNCLAMPED- See Also:
-
NON_UNIFORM
public static final int NON_UNIFORM- See Also:
-
-
Constructor Details
-
BSpline
-
-
Method Details
-
eval
protected void eval(double[] p) Description copied from class:ParametricCurveThe eval method evaluates a point on a curve given a parametric value "t". The parametric value "t" is stored in the last index location of the specified double array. This value should not be changed. The dimension of the point to evaluate is p.length - 1. The result of the evaluation is placed in index locations 0 .. p.length - 2 (inclusive). The eval method should remain protected except for those curves that do no need any preparation to be done in the appendTo method.- Specified by:
evalin classParametricCurve
-
setInterval
public void setInterval(double t_min, double t_max) Specifies the interval that the curve should define itself on. The default interval is [0.0, 1.0]. When the knot-vector type is one of UNIFORM_CLAMPED or UNIFORM_UNCLAMPED and the useDefaultInterval flag is true, then these values will not be used.- Throws:
IllegalArgumentException- If t_min > t_max.- See Also:
-
t_min
public double t_min()Returns the starting interval value.- See Also:
-
t_max
public double t_max()Returns the finishing interval value.- See Also:
-
getSampleLimit
public int getSampleLimit()Description copied from class:ParametricCurveThe sample limit specifies how many additional subdivisions are done to ensure that there are no missed pieces of the curve. The sample limit must be >= 0.- Specified by:
getSampleLimitin classParametricCurve
-
setSampleLimit
public void setSampleLimit(int limit) Sets the sample-limit. For more information on the sample-limit, see the BinaryCurveApproximationAlgorithm class. The default sample-limit is 1.- Throws:
IllegalArgumentException- If sample-limit < 0.- See Also:
-
getDegree
public int getDegree()Returns the degree of the curve.- See Also:
-
setDegree
public void setDegree(int d) Sets the degree of the curve. The degree specifies how many controls points have influence when computing a single point on the curve. Specifically, degree + 1 control points are used. The degree must be greater than 0. A degree of 1 is linear, 2 is quadratic, 3 is cubic, etc. Warning: Increasing the degree by 1 doubles the number of computations required. The default degree is 3 (cubic).- Throws:
IllegalArgumentException- If degree <= 0.- See Also:
-
getKnotVector
Returns the knot-vector for this curve.- See Also:
-
setKnotVector
Sets the knot-vector for this curve. When the knot-vector type is one of UNIFORM_CLAMPED or UNIFORM_UNCLAMPED then the values in the knot-vector will not be used.- Throws:
IllegalArgumentException- If the value-vector is null.- See Also:
-
getUseDefaultInterval
public boolean getUseDefaultInterval()Returns the value of the useDefaultInterval flag.- See Also:
-
setUseDefaultInterval
public void setUseDefaultInterval(boolean b) Sets the value of the useDefaultInterval flag. When the knot-vector type is one of UNIFORM_CLAMPED or UNIFORM_UNCLAMPED and the useDefaultInterval flag is true, then default values will be computed for t_min and t_max. Otherwise t_min and t_max are used as the interval.- See Also:
-
getKnotVectorType
public int getKnotVectorType()Returns the type of knot-vector to use.- See Also:
-
setKnotVectorType
public void setKnotVectorType(int type) Sets the type of knot-vector to use. There are 3 types, UNIFORM_CLAMPED, UNIFORM_UNCLAMPED and NON_UNIFORM. NON_UNIFORM can be thought of as user specified. UNIFORM_CLAMPED and UNIFORM_UNCLAMPED are standard knot-vectors for the B-Spline.- Throws:
IllegalArgumentException- If the knot-vector type is unknown.- See Also:
-
appendTo
There are two types of requirements for this curve, common requirements and requirements that depend on the knotVectorType. The common requirements are that the group-iterator must be in range and the number of points (group size) must be greater than the degree. If the knot-vector type is NON_UNIFORM (user specified) then there are additional requirements, otherwise there are no additional requirements. The additional requirements when the knotVectorType is NON_UNIFORM are that the internal-knot vector must have an exact size of degree + numPts + 1, where degree is specified by the setDegree method and numPts is the group size. Also, the knot-vector values must be non-decreasing. If any of these requirements are not met, then IllegalArgumentException is thrown -
N
protected double N(double t, int i) Non-recursive implementation of the N-function. -
resetMemory
public void resetMemory()Description copied from class:CurveResets the shared memory to the initial state.- Overrides:
resetMemoryin classCurve
-