public class KnotVector extends java.lang.Object implements java.lang.Cloneable, javolution.xml.XMLSerializable, javolution.lang.ValueType
Modified by: Joseph A. Huwaldt
Modifier and Type | Method and Description |
---|---|
double[][] |
basisFunctionDerivatives(int span,
double s,
int grade)
Calculates all the derivatives of all the unweighted basis functions from
0 up to the given grade, d^{grade}Nik(s)/d^{grade}s . |
double[] |
basisFunctions(double s)
Returns the basis function values for the given parameter value (Nik(s)).
|
double[] |
basisFunctions(int span,
double s)
Returns the unweighted basis function values for the given parameter value
(Nik(s)), when the span that the parameter value lies in is already known.
|
static KnotVector |
bezierKnotVector(int degree)
Return a knot vector that can be used to create a Bezier curve segment of the
specified degree using the BasicNurbsCurve class.
|
java.lang.Object |
clone()
Returns a copy of this KnotVector instance
allocated by the calling thread
(possibly on the stack). |
KnotVector |
copy()
Returns a copy of this KnotVector instance
allocated by the calling thread
(possibly on the stack). |
boolean |
equals(java.lang.Object obj)
Compares this ControlPoint against the specified object for strict equality (same
values and same units).
|
int |
findMultiplicity(int index)
Find the multiplicity of the knot with the specified index in this knot vector.
|
int |
findSpan(double s)
Returns the span (position of corresponding knot values in knot vector) a given
parameter value belongs to.
|
Float64 |
get(int i)
Return the knot at the specified index.
|
Float64Vector |
getAll()
Return the knot values as an vector of
Float64 values. |
int |
getDegree()
Return the degree of the KnotVector
|
int |
getNu()
Return the length of the knot vector (nu).
|
int |
getNumberOfSegments()
Return the number of segments in the knot vector.
|
double |
getValue(int i)
Return the knot value at a specific index as a
double . |
int |
hashCode()
Returns the hash code for this parameter.
|
boolean |
isOpen()
Return
true if the knot vector is open and false if it is
closed. |
boolean |
isValid()
Return
true if this KnotVector contains valid and finite numerical
components. |
int |
length()
Return the number of elements in the knot vector.
|
static KnotVector |
newInstance(int degree,
double... knots)
Create a KnotVector from the given knot values of the desired degree.
|
static KnotVector |
newInstance(int degree,
Float64Vector knots)
Create a KnotVector from the given knot values of the desired degree.
|
static KnotVector |
newInstance(int degree,
java.util.List<java.lang.Double> knots)
Create a KnotVector from the given list of knot values of the desired degree.
|
static void |
recycle2DArray(double[][] arr)
Recycle any 2D array of doubles that was created by this classes factory methods.
|
KnotVector |
reverse()
Return a copy of this knot vector with the parameterization reversed.
|
java.lang.String |
toString()
Returns the string representation of this knot vector that consists of the degree
followed by the knot values.
|
javolution.text.Text |
toText()
Returns the text representation of this knot vector that consists of the degree
followed by the knot values.
|
public static KnotVector newInstance(int degree, Float64Vector knots)
degree
- degree of NURBS curveknots
- knot values. May not be null.java.lang.IllegalArgumentException
- if the knot vector is not valid.public static KnotVector newInstance(int degree, java.util.List<java.lang.Double> knots) throws java.lang.IllegalArgumentException
degree
- degree of NURBS curveknots
- A list of knot values. May not be null.java.lang.IllegalArgumentException
- if the knot vector is not valid.public static KnotVector newInstance(int degree, double... knots) throws java.lang.IllegalArgumentException
degree
- degree of NURBS curveknots
- knot values. May not be null.java.lang.IllegalArgumentException
- if the knot vector is not valid.public static KnotVector bezierKnotVector(int degree)
degree
- The degree of the knot vector to return.public int findSpan(double s)
s
- parameter value to find the span forpublic double[] basisFunctions(double s)
s
- Parameter value to calculate basis functions for.public double[] basisFunctions(int span, double s)
span
- The span s
lies ins
- The parameter value to calculate basis functions for.public double[][] basisFunctionDerivatives(int span, double s, int grade)
0
up to the given grade, d^{grade}Nik(s)/d^{grade}s
.
Examples:
1st derivative (grade = 1), this returns [Nik(s), dNik(s)/ds]
;
2nd derivative (grade = 2), this returns [Nik(s), dNik(s)/ds, d^2Nik(s)/d^2s]
; etc.
span
- The span s
lies ins
- The parameter value to calculate basis functions for.grade
- The grade to calculate the derivatives for (1=1st derivative, 2=2nd
derivative, etc).KnotVector.recycle2DArray(arr)
when no longer needed.java.lang.IllegalArgumentException
- if the grade is < 0.basisFunctions(double)
,
recycle2DArray(double[][])
public int getNu()
public int length()
public Float64Vector getAll()
Float64
values.public Float64 get(int i)
i
- Index to get knot value fori
public double getValue(int i)
double
.i
- Index to get knot value fori
returned as a double
.public int getDegree()
public int getNumberOfSegments()
public boolean isOpen()
true
if the knot vector is open and false
if it is
closed.public boolean isValid()
true
if this KnotVector contains valid and finite numerical
components. A value of false
will be returned if any of the knot
values are NaN or Inf.public int findMultiplicity(int index)
index
- the index of the knot to observe (the largest index of a repeated
series of knots).public KnotVector reverse()
public KnotVector copy()
allocated
by the calling thread
(possibly on the stack).copy
in interface javolution.lang.ValueType
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
allocated
by the calling thread
(possibly on the stack).clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Never thrown.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare with.true
if this point is identical to that point;
false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public javolution.text.Text toText()
{degree=2,{0.0, 0.0, 0.0, 1.0, 1.0, 1.0}}
public java.lang.String toString()
{degree=2,{0.0, 0.0, 0.0, 1.0, 1.0, 1.0}}
toString
in class java.lang.Object
public static void recycle2DArray(double[][] arr)
arr
- The array to be recycled. The array must have been created by this class
or by CurveUtils.allocate2DArray()!