Package d3delaunayforprocessing
Class Delaunay
java.lang.Object
d3delaunayforprocessing.Delaunay
public class Delaunay
extends java.lang.Object
d3-delaunay-for-processing
To port the d3-delaunay library to Java using the delaunator-java library by
waveware4ai
This is the Delaunay class
- Since:
- 2022-12-22
-
Field Summary
Fields Modifier and Type Field Description org.waveware.delaunator.Delaunator
_delaunator
int[]
_hullIndex
int[]
collinear
int[]
halfedges
The halfedge indexes as an int array: [ j0, j1, ...]int[]
hull
An int array of point indexes that form the convex hull in counterclockwise order.int[]
indeges
The incoming halfedge indexes as a int array [ e0, e1, e2, ...].double[]
points
An 1D double array of all the points input.static double
tau
int[]
triangles
The triangle vertex indexes as an int array [ i0, j0, k0, i1, j1, k1, ...] -
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
_init()
int
_step(int i, double x, double y)
int
find(double x, double y)
Returns the index of the input point that is closest to the specified point (x, y).int
find(double x, double y, int i)
Returns the index of the input point that is closest to the specified point (x, y).int
findFloat(float x, float y)
Returns the index of the input point that is closest to the specified point (x, y).int
findFloat(float x, float y, int i)
Returns the index of the input point that is closest to the specified point (x, y).static Delaunay
from(double[][] points)
This method return a new Delaunay instant from a double[][] array like this [ [x0, y0] , [ x1, y1] , ...].static Delaunay
fromFloat(float[][] points)
This method return a new Delaunay instant from a double[][] array like this [ [x0, y0] , [ x1, y1] , ...].double[][]
hullPolygon()
Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], ...float[][]
hullPolygonFloat()
Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], ...static int
indexOfIntArray(int[] array, int key)
int[]
neighbors(int i)
Returns an int array of the indexes of the neighboring points to the specified point i.void
renderHull(Polygon context)
void
renderTriangle(int i, Polygon context)
double[][]
trianglePolygon(int i)
Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the triangle i.float[][]
trianglePolygonFloat(int i)
Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the triangle i.double[][][]
trianglePolygons()
Returns an array of the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the each triangle.float[][][]
trianglePolygonsFloat()
Returns an array of the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the each triangle.Voronoi
voronoi()
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ 0, 0, 960, 500 ]Voronoi
voronoi(double[] bounds)
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ xmin, ymin, xmax, ymax ].Voronoi
voronoiFloat(float[] bounds)
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ xmin, ymin, xmax, ymax ].
-
Field Details
-
tau
public static double tau -
_delaunator
public org.waveware.delaunator.Delaunator _delaunator -
indeges
public int[] indegesThe incoming halfedge indexes as a int array [ e0, e1, e2, ...]. For each point i, inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the halfedge index is -1; for points on the convex hull, the incoming halfedge is on the convex hull; for other points, the choice of incoming halfedge is arbitrary. -
_hullIndex
public int[] _hullIndex -
points
public double[] pointsAn 1D double array of all the points input. Like this [ x0, y0, x1, y1, ...] -
collinear
public int[] collinear -
halfedges
public int[] halfedgesThe halfedge indexes as an int array: [ j0, j1, ...] -
hull
public int[] hullAn int array of point indexes that form the convex hull in counterclockwise order. If the points are collinear, returns them ordered. -
triangles
public int[] trianglesThe triangle vertex indexes as an int array [ i0, j0, k0, i1, j1, k1, ...]
-
-
Constructor Details
-
Delaunay
public Delaunay(double[] points)This is the recommanded way to create a new Delaunay instant. It accepts a 2D double array like this[x0, y0, x1, y1 , ...]- Parameters:
points
- the input points
-
Delaunay
public Delaunay(float[] points)This is the recommanded way to create a new Delaunay instant. It accepts a 2D double array like this[x0, y0, x1, y1 , ...]. Float version- Parameters:
points
- the input points
-
-
Method Details
-
from
This method return a new Delaunay instant from a double[][] array like this [ [x0, y0] , [ x1, y1] , ...].- Parameters:
points
- the input points- Returns:
- a Delaunay Object
-
fromFloat
This method return a new Delaunay instant from a double[][] array like this [ [x0, y0] , [ x1, y1] , ...]. Input with float.- Parameters:
points
- the input points- Returns:
- a Delaunay Object
-
_init
public void _init() -
voronoi
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ 0, 0, 960, 500 ]- Returns:
- a Voronoi object
-
voronoi
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ xmin, ymin, xmax, ymax ].- Parameters:
bounds
- the bounds of the Voronoi graph- Returns:
- a Voronoi object
-
voronoiFloat
Returns the corresponding Voronoi instant.The diagram will be clipped to the specified bounds = [ xmin, ymin, xmax, ymax ]. Float version- Parameters:
bounds
- the bounds of the Voronoi graph- Returns:
- a Voronoi object
-
neighbors
public int[] neighbors(int i)Returns an int array of the indexes of the neighboring points to the specified point i.- Parameters:
i
- the index of the point- Returns:
- an int array of the indexes of the neighboring points
-
find
public int find(double x, double y)Returns the index of the input point that is closest to the specified point (x, y). The search is started at the point 0.- Parameters:
x
- point.xy
- point.y- Returns:
- the found point index
-
find
public int find(double x, double y, int i)Returns the index of the input point that is closest to the specified point (x, y). The search is started at the specified point i.- Parameters:
x
- point.xy
- point.yi
- the index to start search- Returns:
- the found point index
-
findFloat
public int findFloat(float x, float y)Returns the index of the input point that is closest to the specified point (x, y). The search is started at the point 0. Float version- Parameters:
x
- point.xy
- point.y- Returns:
- the found point index
-
findFloat
public int findFloat(float x, float y, int i)Returns the index of the input point that is closest to the specified point (x, y). The search is started at the specified point i. Float version- Parameters:
x
- point.xy
- point.yi
- the index to start search- Returns:
- the found point index
-
_step
public int _step(int i, double x, double y)- Parameters:
i
-x
-y
-- Returns:
- int
-
renderHull
-
hullPolygon
public double[][] hullPolygon()Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], ... , [ x0, y0 ]] representing the convex hull.- Returns:
- an array representing the convex hull
-
hullPolygonFloat
public float[][] hullPolygonFloat()Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], ... , [ x0, y0 ]] representing the convex hull. Float version- Returns:
- an array representing the convex hull
-
renderTriangle
- Parameters:
i
-context
-
-
trianglePolygons
public double[][][] trianglePolygons()Returns an array of the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the each triangle.- Returns:
- an array containing all triangles
-
trianglePolygonsFloat
public float[][][] trianglePolygonsFloat()Returns an array of the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the each triangle. Float version- Returns:
- an array containing all triangles
-
trianglePolygon
public double[][] trianglePolygon(int i)Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the triangle i.- Parameters:
i
- the index of the triangle- Returns:
- an array representing the triangle
-
trianglePolygonFloat
public float[][] trianglePolygonFloat(int i)Returns the closed polygon [ [ x0, y0 ], [ x1, y1 ], [ x2, y2 ], [ x0, y0 ] ] representing the triangle i. Float version- Parameters:
i
- the index of the triangle- Returns:
- an array representing the triangle
-
indexOfIntArray
public static int indexOfIntArray(int[] array, int key)
-