Open Fil opened 6 years ago
Another small optimization is using d3.geoStereographicRaw (or inline the definition) instead of d3.geoStereographic.
Skimming through the code, I also recommend:
[x, y, x, y, ...
instead of [[x, y], [x, y], ...
.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).https://github.com/Fil/d3-geo-voronoi/commit/4b9aee7f0bfd84cdc962f97e4dc1d2b9e001f926 uses a direct formula for the stereographic
A good reference presentation :) https://www.dotconferences.com/2019/12/vladimir-agafonkin-algorithmic-performance-optimization-in-practice
Ideas for later:
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!)✓