Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created March 8, 2019 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behreajj/d823c10956b54de7a0cc281ec3d9d5e3 to your computer and use it in GitHub Desktop.
Save behreajj/d823c10956b54de7a0cc281ec3d9d5e3 to your computer and use it in GitHub Desktop.
Mandelbulb
def mandelbulb(points=[],
exponent=Vector((8.0, 8.0, 8.0)),
iterations=32,
exclude_upper=False):
results = []
for point in points:
result = mandelbulb_step(
center=point,
exponent=exponent,
iterations=iterations,
exclude_upper=exclude_upper)
results.append(result)
return results
def cube_mandelbulb(count=32,
collection=context.collection,
name='Mandelbulb',
material=None,
min_corner=Vector((-0.5, -0.5, -0.5)),
max_corner=Vector((0.5, 0.5, 0.5)),
exponent=Vector((8.0, 8.0, 8.0)),
iterations=32,
exclude_upper_mandel=False,
fractal_center=Vector(),
fractal_scale=2.0,
prune_cubes=True,
prune_lower_bound=0.05,
prune_upper_bound=1.0,
min_cube_size=0.15,
max_cube_size=0.975,
cube_pivot=Vector((0.0, 0.0, 0.0)),
easing_func=float_lerp):
grid = gen_3d_grid(
count=count,
offset=fractal_center,
scale=fractal_scale,
min_corner=min_corner,
max_corner=max_corner)
w = grid['width']
h = grid['height']
d = grid['depth']
points = grid['points']
results = mandelbulb(
points=points,
exponent=exponent,
iterations=iterations,
exclude_upper=exclude_upper_mandel)
dimensions = Vector((w, h, d)) / count
obj = visualize_fractal(
collection=collection,
name=name,
material=material,
results=results,
fractal_center=fractal_center,
fractal_scale=fractal_scale,
prune_cubes=prune_cubes,
prune_lower_bound=prune_lower_bound,
prune_upper_bound=prune_upper_bound,
cube_pivot=cube_pivot,
cube_size=dimensions,
min_cube_size=min_cube_size,
max_cube_size=max_cube_size,
easing_func=easing_func)
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment