Fil/d3-geo-voronoi

Faster

Fil opened this issue · 4 comments

Fil commented

Ideas for later:

  • change the arrays into typed arrays when possible (edges => edges2, etc) in the delaunay part
  • use spherical trig for rotation & projection (instead of geoRotation+geoStereographic)
  • use spherical trig for checking if a triangle is clockwise or CCW (instead of geoArea!)

Another small optimization is using d3.geoStereographicRaw (or inline the definition) instead of d3.geoStereographic.

Skimming through the code, I also recommend:

  • Using flat arrays for points — e.g. [x, y, x, y, ... instead of [[x, y], [x, y], ....
  • Avoiding array allocations as much as possible. This includes chained array.map and slice. Inspect each occurrence of allocating methods and try to rewrite for less allocations (e.g. collapse chained function-style transformation into a single for loop).
Fil commented

4b9aee7 uses a direct formula for the stereographic