@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.