Package org.tinfour.utils
Class BarycentricCoordinates
- java.lang.Object
-
- org.tinfour.utils.BarycentricCoordinates
-
public class BarycentricCoordinates extends Object
Implements utilities for computing Barycentric Coordinates. The algorithm for computing coordinates is based on Hormann, Kai. (2005). "Barycentric Coordinates for Arbitrary Polygons in the Plane -- Technical Report IfI-05-05", Institute fur Informatik, Technische Universitat Clausthal.Development Status: At this time, this class has not been thoroughly reviewed and has undergone only superficial testing.
-
-
Constructor Summary
Constructors Constructor Description BarycentricCoordinates()Standard constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetBarycentricCoordinateDeviation()Gets the deviation of the computed equivalent of the input query (x,y) coordinates based on barycentric coordinates.double[]getBarycentricCoordinates(List<Vertex> polygon, double x, double y)Given a reference point inside a simple, but potentially non-convex polygon, creates an array of barycentric coordinates for the point.
-
-
-
Method Detail
-
getBarycentricCoordinates
public double[] getBarycentricCoordinates(List<Vertex> polygon, double x, double y)
Given a reference point inside a simple, but potentially non-convex polygon, creates an array of barycentric coordinates for the point. The coordinates are normalized, so that their sum is 1.0. This method populates the barycentric deviation member element which may be used as a figure of merit for evaluating the success of the coordinate computation. If the point is not inside the polygon or if the polygon is self-intersecting, the results are undefined and the method may return a null array or a meaningless result. If the point is on the perimeter of the polygon, this method will return a null array.- Parameters:
polygon- list of vertices defining a non-self-intersecting, potentially non-convex polygon.x- the x coordinate of the reference pointy- the y coordinate of the reference point- Returns:
- if successful, a valid array; otherwise a null.
-
getBarycentricCoordinateDeviation
public double getBarycentricCoordinateDeviation()
Gets the deviation of the computed equivalent of the input query (x,y) coordinates based on barycentric coordinates. While the computed equivalent should be an exact match for the query point, errors in implementation or numeric errors due to float-point precision limitations would result in a deviation. Thus, this method provides a diagnostic on the most recent computation. A large non-zero value indicates a potential implementation problem. A small non-zero value indicates an error due to numeric issues.- Returns:
- a positive value, ideally zero but usually a small number slightly larger than that.
-
-