Just to conclude the the code part (from me), I realized while walking this morning that POV-Ray scene description language is such that the ordering of sphere placement would not matter, so just iterate through the keys.
The code before tried to construct the keys by duplicating the raster pattern of the Fractal's __init__ -- quite unnecessarily. def __init__(self, left_x, top_y, right_x, bottom_y, delta_x, delta_y): """Top Left, Top, Far Right, Bottom, x increment, y increment""" As also suggested by F.delta_x below, I also modified Fractal in an obvious way: to accept delta_x and delta_y as arguments, along with: x minimum (left), y maximum (top), x maximum (right), y minimum (bottom). If this were scaffolding in a class setting, a next iteration might involve jiggering the API, to accept (top, left) and (bottom, right) as tuples perhaps. Here's the revised make_pov function: def make_pov(F): """ eat Fractal object, output POV-ray spheres for inclusion in a POV-Ray file """ rows = "" radius = F.delta_x/2 for x,y in F: v = abs(F[(x,y)]) # calibrate by magnitude of stored value if v >= 3: color = "rgb<1,1,1>" elif 3 > v >= 2.5: color = "rgb<1,0.65,0>" elif 2.5 > v >= 1.5: color = "rgb<0.45,0.45,0>" elif 1.5 > y >= 1.0: color = "rgb<0.25,0.25,0>" else: color = "rgb<0.25,0.25,0>" rows += sphere_tmpl.format(x=x, y=y, z=0, radius=radius, color=color) return rows And here's a screen shot of what I get for running the Python below: http://www.flickr.com/photos/kirbyurner/12934900014/lightbox/ def _test2(): # run me and then render me in POV-Ray to see 'fractal' f = Fractal(-2.2, 1.4, 0.8, -1.4, 0.005, 0.005) pov_out.make_file(f) # mandelbrot.pov is the output ...and in bash: povray +Imandelbrot.pov +A[0.1] +W1024 +H768 I've been into Python + Fractals before here on edu-sig. Here's a solution using PIL: http://4dsolutions.net/ocn/fractals.html And in this one I use VPython to play Game of Life (also Chaos Math) on a hexapent: http://4dsolutions.net/ocn/life.html Then there's the Wolfram / NKS stuff ("new kind of science"), very doable in tkinter for example: http://www.frank-buss.de/automaton/rule30.html Lots of people work in this area. I've done nothing with Python and the Mandelbulb. Kirby
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig