mourner / icomesh

Fast JavaScript icosphere mesh generation library for WebGL visualizations
https://observablehq.com/@mourner/fast-icosphere-mesh
ISC License
55 stars 4 forks source link

Alternative pairing function #2

Closed IvanSanchez closed 5 years ago

IvanSanchez commented 5 years ago

Change the pairing function from Cantor's to a 26-bit shift.

IvanSanchez commented 5 years ago

Using 1 << 26 works well with order<=10. There is a speed-up but doesn't seem to be that big (~0.5%):

With Cantor's: Generated a 10-order icosphere (10485762 vertices / 20971520 triangles) in 11.020ms.

With 1 << 26: Generated a 10-order icosphere (10485762 vertices / 20971520 triangles) in 10.968ms.

(disclaimer: benchmark consists of 1 (one) data point)

mourner commented 5 years ago

That's within variance. So I'd rather keep Cantor's pairing function because I think it's cool :)