Package toxi.geom.nurbs
Class KnotVector
java.lang.Object
toxi.geom.nurbs.KnotVector
KnotVector, assembles the knots values of a NURBS and its degree.
- Version:
- 1.0
- Author:
- sg
-
Constructor Summary
ConstructorDescriptionKnotVector
(float[] knots, int degree) Create a Knotvector from the given knot values of the desired degree. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
basisFunctions
(float u) Gets the basis function values for the given u value.double[]
basisFunctions
(int span, float u) Calculates the basis function values for the given u value, when it's already known in which span u lies.float[][]
derivBasisFunctions
(float u, int grade) Calculates the basis functions and its derivatives up to the given grade.float[][]
derivBasisFunctions
(int span, float u, int grade) Calculates the basis functions and its derivatives up to the given grade.int
findSpan
(float u) Finds the span (Position of corresponding knot values in knot vector) a given value belongs to.float
get
(int i) Get the knot value at a specific index.float[]
getArray()
get the knot values as float arrayint
Get the degree of the KnotVectorint
getN()
Return the nuint
boolean
isOpen()
int
length()
void
set
(int i, float val) Set the knot value at a specific index.
-
Constructor Details
-
KnotVector
Create a Knotvector from the given knot values of the desired degree.- Parameters:
knots
- knot valuesdegree
- degree of Nurbs- Throws:
IllegalArgumentException
-
-
Method Details
-
basisFunctions
public double[] basisFunctions(float u) Gets the basis function values for the given u value. This function calculates firstly the span which is needed in order to calculate the basis functions values.- Parameters:
u
- Value to calculate basis functions for.- Returns:
- basis function values
-
basisFunctions
public double[] basisFunctions(int span, float u) Calculates the basis function values for the given u value, when it's already known in which span u lies.- Parameters:
span
- The span u lies inu
- Value to calculate basis functions for.- Returns:
- basis function values
-
derivBasisFunctions
public float[][] derivBasisFunctions(float u, int grade) Calculates the basis functions and its derivatives up to the given grade.- Parameters:
u
- Value to calculate basis functions and derivatives for.grade
- grade to calculate derivations for.- Returns:
- an array of basis function values or derivated basis functions
values. The first array is the degree of dderivation in the
second array rhe values are stored.
Example:
float[]][] f=dersBasisFuns(0.1f, 3); float value=f[0][1]; //In value is know the second value of the basis function derived 0 times stored.
-
derivBasisFunctions
public float[][] derivBasisFunctions(int span, float u, int grade) Calculates the basis functions and its derivatives up to the given grade.- Parameters:
span
- Span the given value lies in.u
- Value to calculate basis functions and derivatives for.grade
- grade to calculate derivations for.- Returns:
- an array of basis function values or derivated basis functions values
- See Also:
-
findSpan
public int findSpan(float u) Finds the span (Position of corresponding knot values in knot vector) a given value belongs to.- Parameters:
u
- value to find span for- Returns:
- Position of span.
-
get
public float get(int i) Get the knot value at a specific index.- Parameters:
i
- Index to get knot value for- Returns:
- the knot value
-
getArray
public float[] getArray()get the knot values as float array- Returns:
- the knot values
-
getDegree
public int getDegree()Get the degree of the KnotVector- Returns:
- Degree of the Knotvector
-
getN
public int getN()Return the nu- Returns:
- Length of the KnotVector
-
getNumberOfSegments
public int getNumberOfSegments() -
isOpen
public boolean isOpen() -
length
public int length() -
set
public void set(int i, float val) Set the knot value at a specific index. After this operation a call to isValid may be needed if one is not sure if the KnotVector with the changed value is valid for a Nurbs.- Parameters:
i
- Index to set knot valueval
- value to set the knot too
-