public class SibsonInterpolator3
extends java.lang.Object
The interpolation weights, also called "Sibson coordinates", are volumes of overlapping Voronoi polyhedra, normalized so that they sum to one for any interpolation point (x1,x2,x3). Various implementations of Sibson interpolation differ primarily in how those volumes are computed.
The basic Sibson interpolant is C1 (that is, it's gradient is continuous) at all points (x1,x2,x3) except at the sample points, where it is C0. Sibson (1981) also described an extension of his interpolant that is everywhere C1 and therefore smoother. This smoother interpolant requires gradients at the sample points, and those gradients can be estimated or specified explicitly.
The use of gradients is controlled by a gradient power. If this power is zero (the default), then gradients are not used. Sibson's (1981) smoother C1 interpolant corresponds to a power of 1.0. Larger powers cause the interpolant to more rapidly approach the linear functions defined by the values and gradients at the sample points.
Sibson's interpolant is undefined at points on or outside the convex hull of sample points. In this sense, Sibson interpolation does not extrapolate; the interpolant is implicitly bounded by the convex hull, and null values are returned when attempting to interpolate outside those bounds.
To extend the interpolant outside the convex hull, this class enables bounds to be set explicitly. When bounds are set, extra ghost samples are added outside the convex hull. These ghost samples have no values, but they create a larger convex hull so that Sibson coordinates can be computed anywhere within the specified bounds. While often useful, this extrapolation feature should be used with care, because the added ghost samples may alter the Sibson interpolant at points inside but near the original convex hull.
References:
Modifier and Type | Class and Description |
---|---|
static class |
SibsonInterpolator3.IndexWeight
Sample index and corresponding interpolation weight (Sibson coordinate).
|
static class |
SibsonInterpolator3.Method
The implementation method.
|
Constructor and Description |
---|
SibsonInterpolator3(float[] x1,
float[] x2,
float[] x3)
Constructs an interpolator with specified sample coordinates.
|
SibsonInterpolator3(float[] f,
float[] x1,
float[] x2,
float[] x3)
Constructs an interpolator with specified samples.
|
SibsonInterpolator3(SibsonInterpolator3.Method method,
float[] x1,
float[] x2,
float[] x3)
Constructs an interpolator with specified method and sample coordinates.
|
SibsonInterpolator3(SibsonInterpolator3.Method method,
float[] f,
float[] x1,
float[] x2,
float[] x3)
Constructs an interpolator with specified method and samples.
|
Modifier and Type | Method and Description |
---|---|
SibsonInterpolator3.IndexWeight[] |
getIndexWeights(float x1,
float x2,
float x3)
Gets sample indices and interpolation weights for the specified point.
|
float |
interpolate(float x1,
float x2,
float x3)
Returns a value interpolated at the specified point.
|
float[][][] |
interpolate(Sampling s1,
Sampling s2,
Sampling s3)
Returns an array of interpolated values sampled on a grid.
|
void |
setBounds(float x1min,
float x1max,
float x2min,
float x2max,
float x3min,
float x3max)
Sets a bounding box for this interpolator.
|
void |
setBounds(Sampling s1,
Sampling s2,
Sampling s3)
Sets bounds for this interpolator using specified samplings.
|
void |
setGradientPower(double gradientPower)
Sets the power of gradients for this interpolator.
|
void |
setGradients(float[] g1,
float[] g2,
float[] g3)
Sets gradients for all samples.
|
void |
setNullValue(float fnull)
Sets the null value for this interpolator.
|
void |
setSamples(float[] f,
float[] x1,
float[] x2,
float[] x3)
Sets the samples to be interpolated.
|
void |
useConvexHullBounds()
If bounds have been set explicitly, this method unsets them,
so that the convex hull of sample points will be used instead.
|
float |
validate(int i)
Interpolates at the i'th sample point without using the i'th sample.
|
float[] |
validate(int[] i)
Interpolates at specified sample points without using those samples.
|
public SibsonInterpolator3(float[] x1, float[] x2, float[] x3)
x1
- array of sample x1 coordinates.x2
- array of sample x2 coordinates.x3
- array of sample x3 coordinates.public SibsonInterpolator3(float[] f, float[] x1, float[] x2, float[] x3)
f
- array of sample values f(x1,x2,x3).x1
- array of sample x1 coordinates.x2
- array of sample x2 coordinates.x3
- array of sample x3 coordinates.public SibsonInterpolator3(SibsonInterpolator3.Method method, float[] x1, float[] x2, float[] x3)
method
- the implementation method.x1
- array of sample x1 coordinates.x2
- array of sample x2 coordinates.x3
- array of sample x3 coordinates.public SibsonInterpolator3(SibsonInterpolator3.Method method, float[] f, float[] x1, float[] x2, float[] x3)
method
- the implementation method.f
- array of sample values f(x1,x2,x3).x1
- array of sample x1 coordinates.x2
- array of sample x2 coordinates.x3
- array of sample x3 coordinates.public void setSamples(float[] f, float[] x1, float[] x2, float[] x3)
f
- array of sample values f(x1,x2,x3).x1
- array of sample x1 coordinates.x2
- array of sample x2 coordinates.x3
- array of sample x3 coordinates.public void setGradients(float[] g1, float[] g2, float[] g3)
g1
- array of 1st components of gradients.g2
- array of 2nd components of gradients.g3
- array of 3rd components of gradients.public void setGradientPower(double gradientPower)
If the gradient power is set to a non-zero value, and if gradients have not been set explicitly, then this method will also estimate gradients for all samples, as described by Sibson (1981).
If bounds are set explicitly, gradient estimates can be improved by setting the bounds before calling this method.
gradientPower
- the gradient power.public void setNullValue(float fnull)
fnull
- the null value.public void setBounds(float x1min, float x1max, float x2min, float x2max, float x3min, float x3max)
If gradients are to be computed (not specified explicitly), it is best to set bounds by calling this method before computing gradients.
x1min
- lower bound on x1.x1max
- upper bound on x1.x2min
- lower bound on x2.x2max
- upper bound on x2.x3min
- lower bound on x3.x3max
- upper bound on x3.public void setBounds(Sampling s1, Sampling s2, Sampling s3)
If gradients are to be computed (not specified explicitly), it is best to set bounds by calling this method before computing gradients.
s1
- sampling of x1.s2
- sampling of x2.s3
- sampling of x3.public void useConvexHullBounds()
public float interpolate(float x1, float x2, float x3)
x1
- the x1 coordinate of the point.x2
- the x2 coordinate of the point.x3
- the x3 coordinate of the point.public float[][][] interpolate(Sampling s1, Sampling s2, Sampling s3)
s1
- the sampling of n1 x1 coordinates.s2
- the sampling of n2 x2 coordinates.s3
- the sampling of n3 x3 coordinates.public SibsonInterpolator3.IndexWeight[] getIndexWeights(float x1, float x2, float x3)
Indices and weights are especially useful in applications where they can be reused, say, to interpolate multiple function values at a single point.
x1
- the x1 coordinate of the point.x2
- the x2 coordinate of the point.x3
- the x3 coordinate of the point.public float validate(int i)
If bounds have not been set explicitly, then this method will return a null value if the validated sample is on the convex hull of samples.
This method does not recompute gradients that may have been estimated using the sample to be validated. Therefore, validation should be performed without using gradients.
i
- the index of the sample to validate.public float[] validate(int[] i)
If bounds have not been set explicitly, then this method will return null values if the validated sample is on the convex hull of samples.
This method does not recompute gradients that may have been estimated using the samples to be validated. Therefore, validation should be performed without using gradients.
i
- array of indices of samples to validate.