|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jmeter.visualizers.Spline3
public class Spline3
This class implements the representation of an interpolated Spline curve.
The curve described by such an object interpolates an arbitrary number of fixed points called nodes. The distance between two nodes should currently be constant. This is about to change in a later version but it can last a while as it's not really needed. Nevertheless, if you need the feature, just write me a note and I'll write it asap.
The interpolated Spline curve can't be described by an polynomial analytic equation, the degree of which would be as high as the number of nodes, which would cause extreme oscillations of the curve on the edges.
The solution is to split the curve accross a lot of little intervals : an interval starts at one node and ends at the next one. Then, the interpolation is done on each interval, according to the following conditions :
This leads to a n-unknow n-equation system to resolve. One can resolve an equation system by several manners ; this class uses the Jacobi iterative method, particularly well adapted to this situation, as the diagonal of the system matrix is strong compared to the other elements. This implies the algorithm always converges ! This is not the case of the Gauss-Seidel algorithm, which is quite faster (it uses intermediate results of each iteration to speed up the convergence) but it doesn't converge in all the cases or it converges to a wrong value. This is not acceptable and that's why the Jacobi method is safer. Anyway, the gain of speed is about a factor of 3 but, for a 100x100 system, it means 10 ms instead of 30 ms, which is a pretty good reason not to explore the question any further :)
Here is a little piece of code showing how to use this class :
// ... float[] nodes = {3F, 2F, 4F, 1F, 2.5F, 5F, 3F}; Spline3 curve = new Spline3(nodes); // ... public void paint(Graphics g) { int[] plot = curve.getPlots(); for (int i = 1; i < n; i++) { g.drawLine(i - 1, plot[i - 1], i, plot[i]); } } // ...
Field Summary | |
---|---|
protected float[][] |
_A
|
protected float[] |
_B
|
protected float[][] |
_coefficients
|
protected int |
_m
|
protected int |
_maxIterations
|
protected float |
_minPrecision
|
protected int |
_n
|
protected float[] |
_r
|
protected float[] |
_rS
|
protected static int |
DEFAULT_MAX_ITERATIONS
|
protected static float |
DEFAULT_PRECISION
|
Constructor Summary | |
---|---|
Spline3(float[] r)
Creates a new Spline curve by calculating the coefficients of each part of the curve, i.e. by resolving the equation system implied by the interpolation condition on every interval. |
Method Summary | |
---|---|
protected boolean |
converge()
Test if the Jacobi resolution of the equation system converges. |
void |
debugCheck()
Manual check of the curve at the interpolated points. |
int |
getDefaultMaxIterations()
|
float |
getDefaultPrecision()
|
int |
getMaxIterations()
|
int[] |
getPlots(int width,
int height)
Computes drawable plots from the curve for a given draw space. |
float |
getPrecision()
|
protected void |
interpolation()
Computes the coefficients of the Spline interpolated curve, on each interval. |
protected void |
jacobi()
Resolves the equation system by a Jacobi algorithm. |
protected float |
precision(float[] oldX,
float[] newX)
Computes the current precision reached. |
void |
setMaxIterations(int iterations)
|
void |
setPrecision(float precision)
|
void |
setToDefaultMaxIterations()
|
void |
setToDefaultPrecision()
|
float |
value(float t)
Computes a (vertical) Y-axis value of the global curve. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected float[][] _coefficients
protected float[][] _A
protected float[] _B
protected float[] _r
protected float[] _rS
protected int _m
protected int _n
protected static final float DEFAULT_PRECISION
protected static final int DEFAULT_MAX_ITERATIONS
protected float _minPrecision
protected int _maxIterations
Constructor Detail |
---|
public Spline3(float[] r)
r
- an array of float containing the vertical coordinates of the
nodes to interpolate ; the vertical coordinates start at 0 and
are equidistant with a step of 1.Method Detail |
---|
protected void interpolation()
AX=B
protected void jacobi()
protected boolean converge()
protected float precision(float[] oldX, float[] newX)
public float value(float t)
t
- abscissa
public void debugCheck()
public int[] getPlots(int width, int height)
width
- width within the plots have to be computedheight
- height within the plots are expected to be drawed
width
parameter)public void setPrecision(float precision)
public float getPrecision()
public void setToDefaultPrecision()
public float getDefaultPrecision()
public void setMaxIterations(int iterations)
public int getMaxIterations()
public void setToDefaultMaxIterations()
public int getDefaultMaxIterations()
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |