Coder Social home page Coder Social logo

voronoi.find radius? about d3-delaunay HOT 4 CLOSED

d3 avatar d3 commented on April 28, 2024
voronoi.find radius?

from d3-delaunay.

Comments (4)

Fil avatar Fil commented on April 28, 2024

The third argument is currently i, a starting node (default: 0). It helps speed up the search a bit when you start close to the solution (e.g. when you track a mouse's movements).

In d3-voronoi this is an internal value, that is updated after each search. I can't think of a use-case where it would be useful to have it in the API.

from d3-delaunay.

martgnz avatar martgnz commented on April 28, 2024

My doubt was in regards implementing something like your block but with a distance-limited interaction. Using d3-voronoi you can just a third argument for the radius.

How would you do something like that with this library? For example, by passing a number close to the current index?

from d3-delaunay.

Fil avatar Fil commented on April 28, 2024

You can always check the distance between your point and the site found, something like (pseudocode):

v.find_with_radius = function(x,y, radius) {
  n = v.find(x,y);
  if (n !== null && distance(site[n], [x,y]) < radius) return n;
}

But I wonder if it should not be put into the API in lieu of [site]. @mbostock we can prepare a PR if you agree with this change.

from d3-delaunay.

mbostock avatar mbostock commented on April 28, 2024

The radius (distance) test happens after finding the closest site; it doesn’t optimize the search. So, you should perform your radius test after calling find, as @Fil suggests.

The reason that find takes a starting index is that I don’t want find to mutate the internal state of the delaunay instance (as d3-voronoi does). By keeping the internal state immutable, you have greater flexibility in employing your search optimizations.

from d3-delaunay.

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.