PathFinding.js
PathFinding.js copied to clipboard
Grid matrix setup on browser pixels
Hi, I am using this library to draw path on HTML canvas.
I am facing performance issue when I create grid matrix with pixel number. Any idea how I can create grid matrix to overcome this performance hit?
That's the limitation of the a* algorithm, its fast but if you throw a lot of nodes at it it can become slow. I suggest instead of using pixel you define areas or zones and feed that as nodes into the algorithm. For example something like this: https://youtu.be/CattLrDZt3o?t=594 (start at 9:54) you need a weighted pre-calculated graph for that, which this lib does not do but someone already implemented in a fork (see https://github.com/qiao/PathFinding.js/pull/151 )
@brean can u pls help me how to divide a 1000 x1000 pixels into zones/areas?
@yaswanthakula that highly depends on your scenario and what exactly you want to do. For a general solution you could do something like every 100th pixel and create 10x10 zones or you can create something based on an existing road network (like the guy in the youtube video i posted did).
Exactly there I got stuck @brean Can you please help me with a piece of code how to create a zone each with 100 pixels and feed it as a node to grid. I checked that video but I didn't get how he created those zones for the grid.
Kindly help me with this.