org.jzy3d.maths.algorithms.interpolation.bernstein
Class Spline3D

java.lang.Object
  extended by org.jzy3d.maths.algorithms.interpolation.bernstein.Spline3D

public class Spline3D
extends Object

This is a generic 3D B-Spline class for curves of arbitrary length, control handles and patches are created and joined automatically as described here: ibiblio.org/e-notes/ Splines/Bint.htm

Thanks to a bug report by Aaron Meyers (http://universaloscillation.com) the computeVertices(int) method has a slightly changed behaviour from version 0014 onwards. In earlier versions erroneous duplicate points would be added near each given control point, which lead to various weird results.

The new behaviour of the curve interpolation/computation is described in the docs for the computeVertices(int) method below.

Version:
0014 Added user adjustable curve tightness control, 0015 Added JAXB annotations and List support for dynamic building of spline

Field Summary
 BernsteinPolynomial bernstein
           
 float[] bi
           
 Coord3d[] coeffA
           
static float DEFAULT_TIGHTNESS
           
 Coord3d[] delta
           
protected  float invTightness
           
protected  int numP
           
 List<Coord3d> pointList
           
protected  Coord3d[] points
           
protected  float tightness
           
 List<Coord3d> vertices
           
 
Constructor Summary
Spline3D()
          Constructs an empty spline container with default curve tightness.
Spline3D(Coord3d[] pointArray)
           
Spline3D(Coord3d[] pointArray, BernsteinPolynomial b, float tightness)
           
Spline3D(List<Coord3d> rawPoints)
           
Spline3D(List<Coord3d> rawPoints, BernsteinPolynomial b, float tightness)
           
 
Method Summary
 Spline3D add(Coord3d p)
          Adds the given point to the list of control points.
 Spline3D add(float x, float y, float z)
           
 List<Coord3d> computeVertices(int res)
           Computes all curve vertices based on the resolution/number of subdivisions requested.
protected  void findCPoints()
           
 List<Coord3d> getDecimatedVertices(float step)
           
 int getNumPoints()
          Returns the number of key points.
 List<Coord3d> getPointList()
           
 float getTightness()
           
 Spline3D setPointList(List<Coord3d> plist)
           
 Spline3D setTightness(float tightness)
          Sets the tightness for future curve interpolation calls.
 void updateCoefficients()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIGHTNESS

public static final float DEFAULT_TIGHTNESS
See Also:
Constant Field Values

points

protected Coord3d[] points

pointList

public List<Coord3d> pointList

vertices

public List<Coord3d> vertices

bernstein

public BernsteinPolynomial bernstein

delta

public Coord3d[] delta

coeffA

public Coord3d[] coeffA

bi

public float[] bi

tightness

protected float tightness

invTightness

protected float invTightness

numP

protected int numP
Constructor Detail

Spline3D

public Spline3D()
Constructs an empty spline container with default curve tightness. You need to populate the spline manually by using add(Coord3d).


Spline3D

public Spline3D(List<Coord3d> rawPoints)
Parameters:
rawPoints - list of control point vectors

Spline3D

public Spline3D(List<Coord3d> rawPoints,
                BernsteinPolynomial b,
                float tightness)
Parameters:
rawPoints - list of control point vectors
b - predefined Bernstein polynomial (good for reusing)
tightness - default curve tightness used for the interpolated vertices setTightness(float)

Spline3D

public Spline3D(Coord3d[] pointArray)

Spline3D

public Spline3D(Coord3d[] pointArray,
                BernsteinPolynomial b,
                float tightness)
Parameters:
pointArray - array of control point vectors
b - predefined Bernstein polynomial (good for reusing)
tightness - default curve tightness used for the interpolated vertices setTightness(float)
Method Detail

add

public Spline3D add(float x,
                    float y,
                    float z)

add

public Spline3D add(Coord3d p)
Adds the given point to the list of control points.

Parameters:
p -
Returns:
itself

computeVertices

public List<Coord3d> computeVertices(int res)

Computes all curve vertices based on the resolution/number of subdivisions requested. The higher, the more vertices are computed:

(number of control points - 1) * resolution + 1

Since version 0014 the automatic placement of the curve handles can also be manipulated via the setTightness(float) method.

Parameters:
res - the number of vertices to be computed per segment between original control points (incl. control point always at the start of each segment)
Returns:
list of Coord3d vertices along the curve

findCPoints

protected void findCPoints()

getDecimatedVertices

public List<Coord3d> getDecimatedVertices(float step)

getNumPoints

public int getNumPoints()
Returns the number of key points.

Returns:
the numP

getPointList

public List<Coord3d> getPointList()
Returns:
the pointList

getTightness

public float getTightness()
Returns:
the spline3d tightness
Since:
0014 (rev.216)
See Also:
setTightness(float)

setPointList

public Spline3D setPointList(List<Coord3d> plist)
Parameters:
pointList - the pointList to set

setTightness

public Spline3D setTightness(float tightness)
Sets the tightness for future curve interpolation calls. Default value is 0.25. A value of 0.0 equals linear interpolation between the given curve input points. Curve behaviour for values outside the 0.0 .. 0.5 interval is unspecified and becomes increasingly less intuitive. Negative values are possible too and create interesting results (in some cases).

Parameters:
tightness - the tightness value used for the next call to computeVertices(int)
Since:
0014 (rev. 216)

updateCoefficients

public void updateCoefficients()