VOOZH about

URL: https://www.geeksforgeeks.org/javascript/d3-js-delaunay-from-method/

⇱ D3.js Delaunay.from() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

D3.js Delaunay.from() Method

Last Updated : 8 Mar, 2024

The delaunay.from() method returns the Delaunay triangulation for the given array of points or the function that returns the points. This method takes an array of points and optional accessors for x and y coordinates. It returns a Delaunay object that provides various methods for working with triangulation, such as rendering points, accessing triangles, and computing the convex hull.

Syntax:

 delaunay.from(fx, fy)

Parameters:

  • fx: A function that returns the x-coordinate of a point.
  • fy: A function that returns the y-coordinate of a point.

Return Value:

It returns the Delaunay triangulation for the given array of points.

Example 1: This example shows the basic use of delaunay.from() method to create Delaunay triangulation.

Output:

👁 Screenshot-2024-03-01-220829

Example 2: This example explicitly uses d3.Delaunay.from() method to create the Delaunay triangulation from the set of random points.

Comment
Article Tags: