Code Monkey home page Code Monkey logo

Comments (6)

mbostock avatar mbostock commented on July 21, 2024

Here’s a reduction:

var voronoi = d3.voronoi();

voronoi([
  [399.999779, 0],
  [399.999780, 0]
]);

In short the problem is the rounding applied during construction isn’t enough to prevent certain numerical instabilities; these two points are approximately, but not exactly, coincident. This is probably not something I can fix since this code is ported from Raymond Hill’s implementation of Steven Fortune’s algorithm. However, it might be fixable if this library is rewritten to use Vladimir Agafonkin’s delaunator, so that it first computes the Delaunay triangulation and then derives the dual Voronoi diagram. I believe this is generally considered the more numerically stable approach, and it’ll probably be faster…

from d3-voronoi.

Fil avatar Fil commented on July 21, 2024

https://beta.observablehq.com/d/2e32a5a801b9ed02 shows this is probably fixed now in d3-delaunay

I'm saying “probably” because d3-delaunay can't yet handle cases with n=2 points, cf d3/d3-delaunay#19

from d3-voronoi.

garrickf avatar garrickf commented on July 21, 2024

Does d3-delaunay allow for a mapping from the Voronoi polygons to data points (with the other attributes in our original data), like d3-voronoi does? I wanted to use this because of the ability to make it easier to hover over points in a scatter plot, but I'm also running into the issue of some of my data points being approximately coincident.

from d3-voronoi.

mbostock avatar mbostock commented on July 21, 2024

Does d3-delaunay allow for a mapping from the Voronoi polygons to data points

Yes. Cell i in the Voronoi diagram corresponds to input point i.

from d3-voronoi.

garrickf avatar garrickf commented on July 21, 2024

Does d3-delaunay allow for a mapping from the Voronoi polygons to data points

Yes. Cell i in the Voronoi diagram corresponds to input point i.

Thanks for the quick reply! I think my issue might be different: the number of cells I get is less than the number of points I pass in, so perhaps some of my points are actually coincident? I found a way to create a mapping for at least some of my points that have cells, which will probably suffice for hovering over information. Thanks for your help!

from d3-voronoi.

Fil avatar Fil commented on July 21, 2024

It will indeed be fixed by d3/d3-delaunay#64

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.