Class Delaunay<P>

Delaunay triangulation

Type Parameters

  • P

Constructors

  • Returns the Delaunay triangulation for the given flat array [x0, y0, x1, y1, …] of points.

    Type Parameters

    • P

    Parameters

    • points: ArrayLike<number>

    Returns Delaunay<P>

Methods

  • 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. If i is not specified, it defaults to zero.

    Parameters

    • x: number
    • y: number
    • Optional i: number

    Returns number

  • Returns an iterable over the indexes of the neighboring points to the specified point i. The iterable is empty if i is a coincident point.

    Parameters

    • i: number

    Returns IterableIterator<number>

  • Renders the edges of the Delaunay triangulation to an SVG path string.

    Returns string

  • Renders the edges of the Delaunay triangulation to the specified context. The specified context must implement the context.moveTo and context.lineTo methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Renders the convex hull of the Delaunay triangulation to an SVG path string.

    Returns string

  • Renders the convex hull of the Delaunay triangulation to the specified context. The specified context must implement the context.moveTo and context.lineTo methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Renders the input points of the Delaunay triangulation to an SVG path string as circles with radius 2.

    Returns string

  • Renders the input points of the Delaunay triangulation to an SVG path string as circles with the specified radius.

    Parameters

    • context: undefined
    • radius: number

    Returns string

  • Renders the input points of the Delaunay triangulation to the specified context as circles with the specified radius. If radius is not specified, it defaults to 2. The specified context must implement the context.moveTo and context.arc methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Renders triangle i of the Delaunay triangulation to an SVG path string.

    Parameters

    • i: number

    Returns string

  • Renders triangle i of the Delaunay triangulation to the specified context. The specified context must implement the context.moveTo, context.lineTo and context.closePath methods from the CanvasPathMethods API.

    Parameters

    Returns void

  • Returns the closed polygon [[x0, y0], [x1, y1], [x2, y2], [x0, y0]] representing the triangle i.

    Parameters

    • i: number

    Returns Triangle

  • Returns an iterable over the polygons for each triangle, in order.

    Returns IterableIterator<Triangle>

  • Updates the triangulation after the points have been modified in-place.

    Returns Delaunay<P>

  • Returns the Voronoi diagram for the associated points. When rendering, the diagram will be clipped to the specified bounds = [xmin, ymin, xmax, ymax]. If bounds is not specified, it defaults to [0, 0, 960, 500]. See To Infinity and Back Again for an interactive explanation of Voronoi cell clipping.

    Parameters

    Returns Voronoi<P>

  • Returns the Delaunay triangulation for the given array or iterable of points where each point is an array in the form: [x, y].

    Parameters

    Returns Delaunay<Delaunay.Point>

  • Returns the Delaunay triangulation for the given array or iterable of points. Otherwise, the getX and getY functions are invoked for each point in order, and must return the respective x- and y-coordinate for each point. If that is specified, the functions getX and getY are invoked with that as this. (See Array.from for reference.)

    Type Parameters

    • P

    Parameters

    • points: ArrayLike<P> | Iterable<P>
    • getX: GetCoordinate<P, ArrayLike<P> | Iterable<P>>
    • getY: GetCoordinate<P, ArrayLike<P> | Iterable<P>>
    • Optional that: any

    Returns Delaunay<P>

Properties

halfedges: Int32Array

The halfedge indices as an Int32Array [j0, j1, ...]. For each index 0 <= i < halfedges.length, there is a halfedge from triangle vertex j = halfedges[i] to triangle vertex i.

An Int32Array of point indexes that form the convex hull in counterclockwise order. If the points are collinear, returns them ordered.

inedges: Int32Array

The incoming halfedge indexes as a Int32Array [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.

points: ArrayLike<number>

The coordinates of the points as an array [x0, y0, x1, y1, ...]. Typically, this is a Float64Array, however you can use any array-like type in the constructor.

triangles: Uint32Array

The triangle vertex indices as an Uint32Array [i0, j0, k0, i1, j1, k1, ...]. Each contiguous triplet of indices i, j, k forms a counterclockwise triangle. The coordinates of the triangle's points can be found by going through 'points'.