fiblat = {
const x = (i) => i * phi % 1,
y = (i, n, ε=0) => (i + ε) / (n - 1 + 2 * ε),
θ = (i) => x(i) * 2 * Math.PI,
r = (i, n, ε) => Math.sqrt(y(i, n, ε)),
φ = (i, n, ε) => Math.acos(1 - 2 * y(i, n, ε)),
polarToX = (θ, r) => r * Math.cos(θ),
polarToY = (θ, r) => r * Math.sin(θ),
lngLatToXYZ = (θ, φ, r=1) => [Math.cos(θ) * Math.sin(φ) * r, Math.cos(φ) * r, Math.sin(θ) * Math.sin(φ) * r]
return {
x, y, θ, r, φ,
convert: { polarToX, polarToY, lngLatToXYZ }
}
}