Class NaturalNeighborElements
- java.lang.Object
-
- org.tinfour.interpolation.NaturalNeighborElements
-
public class NaturalNeighborElements extends Object
Provides a simple container for the component elements computed during a natural neighbor interpolation. This class is intended to support research and experimentation. This class is not used as part of the internal operations in the NaturalNeighborInterpolator implementation.Interpreting the results If the query is successful, the result type element will be set to SUCCESS. In that case, the interpolated value can be computed as shown in the following example code. This logic is similar to what is used internally by the interpolator.
NaturalNeighborInterpolator nni; // defined by application code NaturalNeighborElements result = nni.getNaturalNeighborElements(x, y); if(result.getResultType() == ResultType.SUCCESS){ // the weight and neighbor arrays will be of the same length double []weight = result.getSibsonCoordinates(); Vertex []neighbor = result.getNaturalNeighbors(); double zSum = 0; for(int i=0; i<weight.length; i++){ zSum += weight[i]*neighbor[i].getZ(); } // zSum is the interpolated value }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNaturalNeighborElements.ResultTypeIndicate the kind of results that are stored in this instance.
-
Constructor Summary
Constructors Constructor Description NaturalNeighborElements(double x, double y, double[] lambda, Vertex[] neighbors, double areaOfEmbeddedPolygon)Constructs a result indicating a successful query.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetAreaOfEmbeddedPolygon()Gets the area of the embedded polygon that was calculated when the natural neighbor elements were constructed.doublegetAreaOfEnvelope()Gets the area of the containing envelope from which natural neighbor coordinates were derived.intgetElementCount()Gets a count for the number of elements (neighbors, Sibson coordinates).Vertex[]getNaturalNeighbors()Gets the set of natural neighbors that were identified for the interpolation that produced these results.NaturalNeighborElements.ResultTypegetResultType()Gets the type of result that produced this instance.double[]getSibsonCoordinates()Gets the weights that were computed for the neighboring vertices during the interpolation operation that produced these results.doublegetX()Gets the Cartesian x coordinate that was specified for the interpolationdoublegetY()Gets the Cartesian y coordinate that was specified for the interpolation
-
-
-
Constructor Detail
-
NaturalNeighborElements
public NaturalNeighborElements(double x, double y, double[] lambda, Vertex[] neighbors, double areaOfEmbeddedPolygon)Constructs a result indicating a successful query. The specified coordinates were located in the interior of the Delaunay triangulation.- Parameters:
x- the Cartesian coordinate of the queryy- the Cartesian coordinate of the querylambda- the Sibson coordinates (weights) for the natural neighborsneighbors- the natural neighborsareaOfEmbeddedPolygon- the area of the polygon that would be formed if a point with the specified coordinates were inserted into the structure.
-
-
Method Detail
-
getResultType
public NaturalNeighborElements.ResultType getResultType()
Gets the type of result that produced this instance.- Returns:
- a valid enumeration instance.
-
getSibsonCoordinates
public double[] getSibsonCoordinates()
Gets the weights that were computed for the neighboring vertices during the interpolation operation that produced these results. For performance reasons, this method returns a direct reference to the member elements of this class, not a safe-copy of the array.If the query point point was not inside the polygon, this method will return an empty, zero-sized array. If the point is on the perimeter of the polygon, this method will also return an empty array.
If the query point point was co-located or nearly co-located with a vertex in the underlying Delaunay triangulation, this method will return an array of size 1.
- Returns:
- a valid array, potentially of length zero if interpolation was unsuccessful.
-
getNaturalNeighbors
public Vertex[] getNaturalNeighbors()
Gets the set of natural neighbors that were identified for the interpolation that produced these results. For performance reasons, this method returns a direct reference to the member elements of this class, not a safe-copy of the array.If the query point point was not inside the polygon, this method will return an empty, zero-sized array. If the point is on the perimeter of the polygon, this method will also return an empty array.
If the query point point was co-located or nearly co-located with a vertex in the underlying Delaunay triangulation, this method will return an array of size 1.
- Returns:
- a valid array, potentially of length zero if interpolation was unsuccessful.
-
getX
public double getX()
Gets the Cartesian x coordinate that was specified for the interpolation- Returns:
- a floating-point value
-
getY
public double getY()
Gets the Cartesian y coordinate that was specified for the interpolation- Returns:
- a floating-point value
-
getAreaOfEnvelope
public double getAreaOfEnvelope()
Gets the area of the containing envelope from which natural neighbor coordinates were derived. This value is the overall area of the polygon defined by the set of natural neighbors.- Returns:
- a positive, finite floating-point value.
-
getAreaOfEmbeddedPolygon
public double getAreaOfEmbeddedPolygon()
Gets the area of the embedded polygon that was calculated when the natural neighbor elements were constructed.- Returns:
- a valid floating-point number.
-
getElementCount
public int getElementCount()
Gets a count for the number of elements (neighbors, Sibson coordinates).- Returns:
- a positive integer, zero if undefined.
-
-