Package WildMagic.LibFoundation.Curves
Class BSplineCurve3f
- java.lang.Object
-
- WildMagic.LibFoundation.Curves.Curve3f
-
- WildMagic.LibFoundation.Curves.SingleCurve3f
-
- WildMagic.LibFoundation.Curves.BSplineCurve3f
-
- All Implemented Interfaces:
java.io.Serializable
,IntegrateInterface
public class BSplineCurve3f extends SingleCurve3f implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class WildMagic.LibFoundation.Curves.Curve3f
Curve3f.PointList
-
-
Field Summary
Fields Modifier and Type Field Description protected Vector3f[]
m_akCtrlPoint
Set of control pointsprotected boolean
m_bLoop
Loop flagprotected int
m_iNumCtrlPoints
Larger than basis control points, because of replicationprotected int
m_iReplicate
the number of replicated control pointsprotected BSplineBasisf
m_kBasis
Spline basisprivate static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description BSplineCurve3f(int iNumCtrlPoints, Vector3f[] akCtrlPoint, int iDegree, boolean bLoop, boolean bOpen)
Construction and destruction.BSplineCurve3f(int iNumCtrlPoints, Vector3f[] akCtrlPoint, int iDegree, boolean bLoop, float[] afKnot)
Open, nonuniform spline.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BSplineCurve3f
CreateApproximation(float[] akValue, int iNumControlPoints, int iDegree)
Create a BSpline curve which best fits a set of 3D points.static BSplineCurve3f
CreateApproximation(Vector3f[] akPoint, int iNumControlPoints, int iDegree)
Create a BSpline curve which best fits a set of 3D points.private void
CreateControl(Vector3f[] akCtrlPoint)
Allocate our control points, with replicationvoid
dispose()
release resourcesvoid
Get(float fTime, Vector3f pkPos, Vector3f pkDer1, Vector3f pkDer2, Vector3f pkDer3)
If you need position and derivatives at the same time, it is more efficient to call these functions.BSplineBasisf
GetBasis()
Access the basis function to compute it without control points.Vector3f
GetControlPoint(int i)
Retrieve a control point.int
GetDegree()
Vector3f
GetFirstDerivative(float fTime)
Get the 3D coordinates of the 1st derivative vector at the point along the curve evaluated for the input time value.float
GetKnot(int i)
int
GetNumCtrlPoints()
Vector3f
GetPosition(float fTime)
The spline is defined for 0 <= t <= 1.Vector3f
GetSecondDerivative(float fTime)
Get the 3D coordinates of the 2nd derivative vector at the point along the curve evaluated for the input time value.Vector3f
GetThirdDerivative(float fTime)
float
GetVariation(float fT0, float fT1, Vector3f pkP0, Vector3f pkP1)
TODO unimplementedboolean
IsLoop()
boolean
IsOpen()
boolean
IsUniform()
void
SetControlPoint(int i, Vector3f rkCtrl)
Control points may be changed at any time.void
SetKnot(int i, float fKnot)
The knot values can be changed only if the basis function is nonuniform and the input index is valid (0 <= i <= n-d-1).-
Methods inherited from class WildMagic.LibFoundation.Curves.SingleCurve3f
GetLength, GetTime, Integrate
-
Methods inherited from class WildMagic.LibFoundation.Curves.Curve3f
GetBinormal, GetCurvature, GetFrame, GetMaxTime, GetMinTime, GetNormal, GetSpeed, GetTangent, GetTime, GetTorsion, GetTotalLength, SetTimeInterval, SubdivideByLength, SubdivideByTime, SubdivideByVariation, SubdivideByVariation
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_iNumCtrlPoints
protected int m_iNumCtrlPoints
Larger than basis control points, because of replication
-
m_akCtrlPoint
protected Vector3f[] m_akCtrlPoint
Set of control points
-
m_bLoop
protected boolean m_bLoop
Loop flag
-
m_kBasis
protected BSplineBasisf m_kBasis
Spline basis
-
m_iReplicate
protected int m_iReplicate
the number of replicated control points
-
-
Constructor Detail
-
BSplineCurve3f
public BSplineCurve3f(int iNumCtrlPoints, Vector3f[] akCtrlPoint, int iDegree, boolean bLoop, boolean bOpen)
Construction and destruction. The caller is responsible for deleting the input arrays if they were dynamically allocated. Internal copies of the arrays are made, so to dynamically change control points or knots you must use the 'SetControlPoint', 'GetControlPoint', and 'Knot' member functions. Uniform spline. The number of control points is n+1 >= 2. The degree of the B-spline is d and must satisfy 1 <= d <= n. The knots are implicitly calculated in [0,1]. If bOpen is 'true', the spline is open and the knots aret[i] = 0, 0 <= i <= d (i-d)/(n+1-d), d+1 <= i <= n 1, n+1 <= i <= n+d+1
If bOpen is 'false', the spline is periodic and the knots aret[i] = (i-d)/(n+1-d), 0 <= i <= n+d+1
If bLoop is 'true', extra control points are added to generate a closed curve. For an open spline, the control point array is reallocated and one extra control point is added, set to the first control point C[n+1] = C[0]. For a periodic spline, the control point array is reallocated and the first d points are replicated. In either case the knot array is calculated accordingly.- Parameters:
iNumCtrlPoints
- number of control points is n+1 >= 2akCtrlPoint
- control point arrayiDegree
- degree of the B-spline is d and must satisfy 1 <= d <= nbLoop
- true to generate a closed loopbOpen
- true for open, false for periodic
-
BSplineCurve3f
public BSplineCurve3f(int iNumCtrlPoints, Vector3f[] akCtrlPoint, int iDegree, boolean bLoop, float[] afKnot)
Open, nonuniform spline. The knot array must have n-d elements. The elements must be nondecreasing. Each element must be in [0,1].- Parameters:
iNumCtrlPoints
- number of control points is n+1 >= 2akCtrlPoint
- control point arrayiDegree
- degree of the B-spline is d and must satisfy 1 <= d <= nbLoop
- true to generate a closed loopafKnot
- knot array
-
-
Method Detail
-
CreateApproximation
public static BSplineCurve3f CreateApproximation(float[] akValue, int iNumControlPoints, int iDegree)
Create a BSpline curve which best fits a set of 3D points.- Parameters:
akValue
- float[] Array of values. The order of the points in the array defines a path.iNumControlPoints
- int Number of control points to use when creating the BSpline curve. The location of the control points are determined to provide a least squares best fit.iDegree
- int Degree of the basis functions to use when creating the BSpline curve.- Returns:
- BSplineCurve3 New instance of the best fit BSpline curve. Even though the fit is for a single set of values, the curve that is created is for 3D set of values in which the x coordinates are used to representing the single value curve. The y and z coordinates are undefined.
-
CreateApproximation
public static BSplineCurve3f CreateApproximation(Vector3f[] akPoint, int iNumControlPoints, int iDegree)
Create a BSpline curve which best fits a set of 3D points.- Parameters:
akPoint
- Point3f[] Array of 3D points. The order of the points in the array defines a path.iNumControlPoints
- Number of 3D control points to use when creating the BSpline curve. The location of the 3D control points are determined to provide a least squares best fit.iDegree
- Degree of the basis functions to use when creating the BSpline curve.- Returns:
- BSplineCurve3 New instance of the best fit BSpline curve.
-
dispose
public void dispose()
release resources
-
Get
public void Get(float fTime, Vector3f pkPos, Vector3f pkDer1, Vector3f pkDer2, Vector3f pkDer3)
If you need position and derivatives at the same time, it is more efficient to call these functions. Pass the addresses of those quantities whose values you want. You may pass null in any argument whose value you do not want.- Parameters:
fTime
- timepkPos
- output positionpkDer1
- output first derivativepkDer2
- output second derivativepkDer3
- output third derivative
-
GetBasis
public BSplineBasisf GetBasis()
Access the basis function to compute it without control points. This is useful for least squares fitting of curves.- Returns:
- reference to basis
-
GetControlPoint
public Vector3f GetControlPoint(int i)
Retrieve a control point. The input index should be valid (0 <= i <= n). If it is invalid, GetControlPoint returns a vector whose components are all MAX_REAL.- Parameters:
i
- index return control point
-
GetDegree
public int GetDegree()
- Returns:
- polynomial degree
-
GetFirstDerivative
public Vector3f GetFirstDerivative(float fTime)
Description copied from class:Curve3f
Get the 3D coordinates of the 1st derivative vector at the point along the curve evaluated for the input time value.- Specified by:
GetFirstDerivative
in classCurve3f
- Parameters:
fTime
- Input time value which must be within the range for which this curve is defined.- Returns:
- New instance created to contain the 3D coordinates of the computed 1st derivative vector. If the time value is less than getMinTime() then the 1st derivative vector at the start of the curve is returned. If the time value is greater than getMaxTime() then the 1st derivative vector at the end of the curve is returned.
- See Also:
GetPosition(float fTime)
-
GetKnot
public float GetKnot(int i)
-
GetNumCtrlPoints
public int GetNumCtrlPoints()
- Returns:
- number of control points
-
GetPosition
public Vector3f GetPosition(float fTime)
The spline is defined for 0 <= t <= 1. If a t-value is outside [0,1], an open spline clamps t to [0,1]. That is, if t > 1, t is set to 1; if t < 0, t is set to 0. A periodic spline wraps to to [0,1]. That is, if t is outside [0,1], then t is set to t-floor(t).- Specified by:
GetPosition
in classCurve3f
- Parameters:
fTime
- time- Returns:
- New instance created to contain the 3D coordinates of the computed position. If the time value is less than getMinTime() then the coordinates of the point at the start of the curve is returned. If the time value is greater than getMaxTime() then the coordinates of the point at the end of the curve is returned.
-
GetSecondDerivative
public Vector3f GetSecondDerivative(float fTime)
Description copied from class:Curve3f
Get the 3D coordinates of the 2nd derivative vector at the point along the curve evaluated for the input time value.- Specified by:
GetSecondDerivative
in classCurve3f
- Parameters:
fTime
- Input time value which must be within the range for which this curve is defined.- Returns:
- New instance created to contain the 3D coordinates of the computed 1st derivative vector. If the time value is less than getMinTime() then the 2nd derivative vector at the start of the curve is returned. If the time value is greater than getMaxTime() then the 2nd derivative vector at the end of the curve is returned.
- See Also:
GetPosition(float)
-
GetThirdDerivative
public Vector3f GetThirdDerivative(float fTime)
- Specified by:
GetThirdDerivative
in classCurve3f
- See Also:
GetPosition(float fTime)
-
GetVariation
public float GetVariation(float fT0, float fT1, Vector3f pkP0, Vector3f pkP1)
TODO unimplemented- Specified by:
GetVariation
in classCurve3f
- Parameters:
fT0
- point 0fT1
- point 1pkP0
- curvature at point 0, may be nullpkP1
- curvature at point 1, may be null- See Also:
Curve3f.SubdivideByVariation(float, int, int, Vector3f[])
-
IsLoop
public boolean IsLoop()
- Returns:
- loop flag
-
IsOpen
public boolean IsOpen()
- Returns:
- Open flag
-
IsUniform
public boolean IsUniform()
- Returns:
- Uniform flag
-
SetControlPoint
public void SetControlPoint(int i, Vector3f rkCtrl)
Control points may be changed at any time. The input index should be valid (0 <= i <= n). If it is invalid, GetControlPoint returns a vector whose components are all MAX_REAL.- Parameters:
i
- indexrkCtrl
- new control point
-
SetKnot
public void SetKnot(int i, float fKnot)
The knot values can be changed only if the basis function is nonuniform and the input index is valid (0 <= i <= n-d-1). If these conditions are not satisfied, GetKnot returns MAX_REAL.- Parameters:
i
- indexfKnot
- new knot
-
CreateControl
private void CreateControl(Vector3f[] akCtrlPoint)
Allocate our control points, with replication- Parameters:
akCtrlPoint
- starting points
-
-