Code Monkey home page Code Monkey logo

Comments (4)

Fil avatar Fil commented on August 22, 2024

I noticed this also, one has to do .extent(null) before calling triangles()
See https://bl.ocks.org/Fil/6c028ce0d9b66d2796bce7f8166f32cd

from d3-voronoi.

Fil avatar Fil commented on August 22, 2024

When we add an extent, the Voronoi cells on the boundary of the rectangle have dangling halfedges. Removing those enables .triangles() to work as expected (and documented).

-         if (i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
+         if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {

This is consistent with what .links() already returns

The documentation could clarify that, in the case of a finite .extent(), what is returned is a subset of the Delaunay triangulation:

- Since the Delaunay triangulation is computed as the dual of the Voronoi diagram, and the Voronoi diagram is clipped by the extent, the Delaunay triangulation is likewise affected by the extent.
+ Since the triangulation is computed as the dual of the Voronoi diagram, and the Voronoi diagram is clipped by the extent, a subset of the Delaunay triangulation is returned.

I have updated my block (https://bl.ocks.org/Fil/6c028ce0d9b66d2796bce7f8166f32cd) to demonstrate this. (Colors are ugly, but could be a basis for something that we link from the documentation.)

from d3-voronoi.

Fil avatar Fil commented on August 22, 2024

An alternative is #13 (claims to return the "full" Delaunay).

from d3-voronoi.

Fil avatar Fil commented on August 22, 2024

Including @adithyaphilip in the discussion.

from d3-voronoi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.