Git Product home page Git Product logo

Comments (1)

Kcnarf avatar Kcnarf commented on July 1, 2024 1

I finally get the issue you're facing with this code

const data = [
        {
          initialWeight: 1,
          initialPos: [0, 0],
        },
        {
          initialWeight: 4,
          initialPos: [0.43038567576932785, 0.5019115451839844],
        },
      ],
      initialPositioner = function (d) {
        return d.initialPos;
      },
      initialWeighter = function (d) {
        return d.initialWeight;
      },
      voronoiMapSimulation = d3VoronoiMap
        .voronoiMapSimulation(data)
        .initialPosition(initialPositioner)
        .initialWeight(initialWeighter)
        .stop();

    let res = voronoiMapSimulation.state();

As you mentioned, weights are indefinitely increasing.

The handleOverweighted1 has a while loop, where the purpose of one iteration is to increase 1 site's weight at a time in order to make it heavy enough (cf. 'P.S.' below). But the increase is too big for very close sites, so that the next iteration increases the other site ... in an infinite manner.
I suspect this is what is going on with your index: 1 and index: 2 data.

The increase of the weights is at least equal to epsilon. The problem is that epsilon is set to 1, which is NOT epsilon-esque at all !
Setting epsilon to its expected value 1E-10 (which is the value used in the underlying d3-weigthed-voronoi package) resolves the issue.

P.S.:
FYI, handleOverweigthedX functions are used when a site no longer produces any cell. This situation is not exceptional, and arises when surrounding sites have heavy weights. handleOverweighted0 tries to lower the weights of the surrounding sites so that the site which initially did not produce any cell will now produces one. On the other hnad, handleOverweighted1 tries to increase the weight of the site that didn't produce any cell.

from d3-voronoi-map.

Related Issues (9)

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.