@sdf3
def sphube(radius=1, n=4, center=ORIGIN):
def psum(*args, n=1):
return pow(sum(map(lambda x: pow(x, n), args)), 1.0 / n)
def f(p):
p = abs(p - center) / radius
px, py, pz = p[:,0], p[:,1], p[:,2]
return psum(px, py, pz, n=n) - 1.0
return f
But n doesn't have to be an integer, and transitions smoothly from 0 to +inf.
It's like a rounded box, but it doesn't have any flat segments.
Maybe add this:
n=1: an octahedron
n=2: a sphere
n=4: a 3D squircle, or "sphube"
n=+inf: a cube
But n doesn't have to be an integer, and transitions smoothly from 0 to +inf.
https://en.wikipedia.org/wiki/Squircle
https://en.wikipedia.org/wiki/Superellipse
It's like a rounded box, but it doesn't have any flat segments.