Hi. I have made a python script to create a Clifford Attractor, that is, a Bezier Curve with 900 vertices. You can see the result here. It is as follows:
# Code adapted by Eduardo Maldonado (Elbrujodelatribu)
# Most of them from addon add_curve_extra_objects
# -> add_curve_spirals.py (see it in your Blender release)
# Info about the attractor in http://paulbourke.net/fractals/clifford/
import bpy
import math
from bpy_extras.object_utils import object_data_add
#ADD VERTICES TO A SPLINE
def makeBezier(spline, vertList):
numPoints = (len(vertList) / 3) - 1
spline.bezier_points.add(numPoints)
spline.bezier_points.foreach_set("co", vertList)
for point in spline.bezier_points:
point.handle_left_type = "AUTO"
point.handle_right_type = "AUTO"
# VERTEX LIST FOR THE ATTRACTOR
vertList = []
# STARTING LOCATION
px = 0.1
py = 0.0
pz = 0.0
# SEED / CONSTANTS
a = -1.4
b = 1.6
c = 1.0
d = 0.7
e = 0.2
f = 0.5
# INIT itr VARIABLE
itr = 0
#CREATE AND ADD VERTICES
while itr < 1000:
#CLIFFORD ATTRACTOR ALGORITHM MODIFIED FOR 3D
newpx = math.sin(a*py) + c*math.cos(a*px)
newpy = math.sin(b*px) + d*math.cos(b*py)
newpz = math.sin(e*px) + f*math.cos(e*pz)
#SAVE CURRENT POINT FOR NEXT ITERATION
px = newpx
py = newpy
pz = newpz
#SKIP FIRST 100 ITERATIONS AND ADD VERTICES
if (itr > 100):
vertList.append( newpx )
vertList.append( newpy )
vertList.append( newpz )
itr += 1
# BUILD THE ATTRACTOR - A BEZIER CURVE
crv = bpy.data.curves.new("Attractor", type = "CURVE")
crv.dimensions = '3D'
crv.splines.new(type = 'BEZIER')
spline = crv.splines[0]
makeBezier(spline, vertList)
# CREATE OBJECT
new_obj = object_data_add(bpy.context, crv)
This is my first python script.
Enjoy it!