Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import math
- # Set the resolution of the point cloud
- resolution = 400
- # Set the maximum number of iterations
- max_iter = 10
- # Set the escape radius
- escape_radius = 2
- # Set the minimum and maximum values for the x, y, and z coordinates
- min_coord = -2
- max_coord = 2
- # Initialize the point cloud data
- points = []
- # Iterate over the x, y, and z coordinates
- for x in range(resolution):
- for y in range(resolution):
- for z in range(resolution):
- # Convert the x, y, and z indices to coordinates in the range [min_coord, max_coord]
- coord_x = min_coord + (x / resolution) * (max_coord - min_coord)
- coord_y = min_coord + (y / resolution) * (max_coord - min_coord)
- coord_z = min_coord + (z / resolution) * (max_coord - min_coord)
- # Initialize the coordinates and the iteration count
- c = complex(coord_x, coord_y)
- z = complex(coord_x, coord_y)
- iteration = 0
- # Iterate the Mandelbrot function until the escape radius is reached or the maximum number of iterations is reached
- while abs(z) < escape_radius and iteration < max_iter:
- z = z**2 + c + complex(0, coord_z)
- iteration += 1
- # If the maximum number of iterations was reached, add the coordinates to the point cloud data
- if iteration == max_iter:
- points.append((coord_x, coord_y, coord_z))
- # Create a new mesh and add it to the scene
- mesh = bpy.data.meshes.new("Julia")
- obj = bpy.data.objects.new("Julia", mesh)
- bpy.context.collection.objects.link(obj)
- # Set the vertices of the mesh using the point cloud data
- mesh.from_pydata(points, [], [])
- mesh.update()
Advertisement
Add Comment
Please, Sign In to add comment