1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-09-25 05:51:41 +02:00

Szudzik function

This commit is contained in:
Justin Lin
2022-04-06 15:56:28 +08:00
parent f5c4320d5e
commit 0b23e5666a

View File

@@ -1 +1,11 @@
function _pt3_hash(p) = floor(abs(p * [73856093, 19349669, 83492791]));
function _pt3_hash(p) =
let(
x = p.x >= 0 ? 2 * p.x : -2 * p.x - 1,
y = p.y >= 0 ? 2 * p.y : -2 * p.y - 1,
z = p.z >= 0 ? 2 * p.z : -2 * p.z - 1,
mx = max(x, y, z),
hash = mx ^ 3 + (2 * mx * z) + z
)
mx == z ? hash + max(x, y) ^ 2 :
y >= x ? hash + x + y :
hash + y;