Last updated

API / geotoolkit / util / DelaunayTriangulator / DelaunayTriangulator

Class: DelaunayTriangulator

util.DelaunayTriangulator.DelaunayTriangulator

Class for triangulation of points using Delaunay algorithm.
The triangulation methods used in this class are based on:

  • Implementation by Mapbox https://github.com/mapbox/delaunator, released under the ISC License
  • Implementation by Paul Bourke ported to JS https://github.com/darkskyapp/delaunay-fast, released under public domain CC0 1.0 Licence
This algorithm triangulates a set of 2D points, and is also capable of triangulating 3D points on the XY plane (by ignoring Z values)

Table of contents

Constructors
Methods

Contents

Constructors

new DelaunayTriangulator()

new DelaunayTriangulator()

Methods

getClassName

getClassName(): string

Returns

string


getClassName

Static getClassName(): string

Returns

string


triangulate

Static triangulate(vertices, is2d?): number[]

Triangulate the given points using Delaunay algorithm.
Different algorithms will be used if providing:

  • 2D points (and setting the "is2d" option to true) will use the so-called "Delaunator" implementation. Note that the Z coordinate will be ignored.
    See https://github.com/mapbox/delaunator.
  • 3D points (default or setting the "is2d" option to false) will use the so-called "Delaunay-Fast" implementation.
    See https://github.com/darkskyapp/delaunay-fast.

Parameters

Name Type Description
verticesnumber[]vertices
Optional is2dbooleanif the given array contains 2 or 3 values per point, false by default. The 3rd coordinate (Z) is ignored, but a different algorithm is used.

Returns

number[]

triangle indices in the form [t1p1,t1p2,t1p3, t2p1,t2p2,t2p3, etc].


triangulateSurface

Static triangulateSurface(vertices3D, options?): number[]

Triangulate the given 3D points using Delaunay algorithm (2D triangulation, Z coordinates will be ignored), this version works best for non-ordered point sets (that do not follow a row or column order layout).
This triangulation will produce more accurate results if the given points form a convex shape (ideally), but if not, concave artifacts can be filtered with the filtergaps options.
Because this triangulation algorithm only takes into account X and Y coordinates, users may want to pre-filter the points, or filter the generated indexed triangles based on potentially invalid Z values to avoid 3D issues.
The implementation used for this triangulation is https://github.com/mapbox/delaunator.

Parameters

Name Type Description
vertices3Dnumber[]3D vertices.
Optional optionsTriangulateSurfacethe triangulation options.

Returns

number[]

triangle indices in the form [t1p1,t1p2,t1p3, t2p1,t2p2,t2p3, etc].