Ok, thank you for straightening it all out regarding the negative/positive values.
I have it generating the basic shape, but the surface is a mess. Have you ever run into that problem?
I changed the XMIN, etc. to -20, and XMAX, etc to 20.
def quat_function(x, y, z):
Z_x = x*0.1
Z_y = y*0.1
Z_z = z*0.1
Z_w = 0
C_x = 0.0 # values of 0 for C make for a unit ball
C_y = 0.0
C_z = 0.0
C_w = 0.0
threshold = 4
max_iterations = 8
len_sq = Z_x*Z_x + Z_y*Z_y + Z_z*Z_z + Z_w*Z_w
threshold_sq = threshold*threshold
for i in range(0, max_iterations):
Z_x, Z_y, Z_z, Z_w = qmul(Z_x, Z_y, Z_z, Z_w, Z_x, Z_y, Z_z, Z_w) # Z*Z
Z_x, Z_y, Z_z, Z_w = qadd(Z_x, Z_y, Z_z, Z_w, C_x, C_y, C_z, C_w) # + C
len_sq = Z_x*Z_x + Z_y*Z_y + Z_z*Z_z + Z_w*Z_w
if len_sq > threshold_sq:
break;
return threshold - math.sqrt(len_sq)
