fivemack: (Default)
Tom Womack ([personal profile] fivemack) wrote2006-11-28 12:58 am

A square Apollonian fractal



Draw a square; in the centre of it, draw a circle. In the largest remaining area of the square, draw a circle. Carry on until you run out of pixels; in the posted image I ran out of pixels fairly early, in the thing I've linked to you'll find the first 128 layers but you'll be able to see the smaller ones only if you've got an SVG editing application. Be warned that rendering images this complex makes Firefox rather lethargic, and may require a plug-in on lesser browsers; don't worry, it hasn't crashed.

If you set up the problem in a computer-algebra package, you find that the centres and radii of the circles, which are defined by sets of three simultaneous quadratic equations and so you might expect to live in an ever-deepening hierarchy of extension fields, are in fact all defined over Q(√ 2); the denominators don't even get too hairy, the largest in the first 128 layers is 257762.

If you don't have magma, you might want to see the log of the run; the layout of the log is obvious from the source code. I know the code's deeply inefficient, I'll need to improve that if I want to go more than a thousand iterations deep, but I don't know of languages which have both a decent Gröbner-basis library and reasonable handling of linked lists and priority queues. Writing priority queues in Magma is probably less painful than writing Gröbner-basis code in C++, but neither's very appealing at 1am, nor my first choice of entertainment at more reasonable hours.

If anyone's got the facility to print images onto large-poster-sized paper in a way in which millimetre-high letters are readable, I'd be interested to see what the highest-depth version I can generate looks like as a physical object; had I rather more energy than I think I do, I'd at least write a Java applet where you could zoom in and pan around ten thousand layers deep.

Pedant

[identity profile] purpletigron.livejournal.com 2006-11-28 08:32 am (UTC)(link)
The largest remaining area of the original square is within the circle!
aldabra: (Default)

Re: Pedant

[personal profile] aldabra 2006-11-28 10:34 am (UTC)(link)
Yes, I want squares in the circles...

Re: Pedant

[identity profile] fivemack.livejournal.com 2006-11-29 03:09 pm (UTC)(link)
Putting squares in the circles turns out to be a rather more difficult coding problem. Were it not for the onerous requirements of a day-job I'd have done it by now; it'll have to wait until the evening.

Re: Pedant

[identity profile] fivemack.livejournal.com 2006-11-29 04:30 pm (UTC)(link)
Image

Eye-searing monstrosities 'r' us!

[identity profile] bugshaw.livejournal.com 2006-11-28 09:15 am (UTC)(link)
We have a machine at work which can print onto Large. I did a poster there for the SFF book launch, it was £15 for an A1 or A0 colour print.

Nice circles!

[identity profile] aardvark179.livejournal.com 2006-11-28 10:40 am (UTC)(link)
Looked at this in Safari with a subversion checkout of WebKit and it renders blindingly fast, but gets some of the text styling wrong.

Illustrator also does this pretty fast, and renders it much better, but I suggest you use the text-anchor attribute to centre the numbers in one direction, and maybe see if one of the baseline attributes can be used to fix them in the other, then you can place them much more central relative to the circles. You also need to do a bit more size adjustment, the higher numbers are prone to overflowing their circles.

I could try using one of the a0 plotters at work, but I'm not going to print an entire page of red so you might want to change make the circle fill white.

[identity profile] aardvark179.livejournal.com 2006-11-28 10:42 am (UTC)(link)
Actually scratch Safari getting the styling wrong. I've just realised that both my Firefox at work and Safari have minimum font sizes set, and they're being respected. D'oh!

[identity profile] fivemack.livejournal.com 2006-11-28 01:28 pm (UTC)(link)
I'll re-render it this evening, after reading up more SVG about text alignment ... I realised the current version is dreadfully profligate on ink and badly-align

I think an effect both pretty and not likely to make the plotter run entirely out of pink might be to draw the square, and then the circles filled in white with no border at 90% of the full radius, so the result looks like a bit of metal with lots of artfully-machined holes in it, like the brakes of an expensive sports car.

Or pure edges: what are the thinnest lines that your plotters can draw sensibly?

[identity profile] aardvark179.livejournal.com 2006-11-28 02:31 pm (UTC)(link)
I think that should work, if I can plot it then it will be via illustrator and PDF. You should know that plotters these days really are just inkjets on steroids.

Heck, if you can't get it to work I'll write a script in NodeBox to do it—procedural graphic design in Python is great.

[identity profile] fivemack.livejournal.com 2006-11-28 03:40 pm (UTC)(link)
I know plotters are inkjets on steroids, but I'm a bit unsure what the capabilities of current inkjets are: 1200dpi = 47dpmm suggests that lines of 0.1mm in thickness (SVG does handle real-life units, doesn't it?) should come out OK, which would be quite impressive over, umm, if I'm targetting A0 I suppose I should render to an 800mm square.

[identity profile] aardvark179.livejournal.com 2006-11-28 03:58 pm (UTC)(link)
They'll go pretty fine, though it depends on altitude and paper stock. I'd say 1mm high letters are unlikely to be very legible, but give it a shot anyway, I can try test printing a portion and then consider discarding text and cicrles below a certain size.

A0 versions with nice thinness

[identity profile] fivemack.livejournal.com 2006-11-29 02:03 pm (UTC)(link)
OK,

http://www.globalphasing.com/~twomack/holy.svg

is the cyan plate with holes in with 1mm borders around them

http://www.globalphasing.com/~twomack/unholy.svg

is the data with 0.1mm borders and holes down to 0.2mm diameter

(both with the image 800mm across for A0 printing)

and http://www.globalphasing.com/~twomack/bigset.cpp has the data embedded in it if you want to process more

Re: A0 versions with nice thinness

[identity profile] aardvark179.livejournal.com 2006-11-29 02:49 pm (UTC)(link)
Those three URLs have one thing in common, I'll give you a clue. It starts with a 4 and ends with a 4.

Re: A0 versions with nice thinness

[identity profile] fivemack.livejournal.com 2006-11-29 03:10 pm (UTC)(link)
Uploaded files for web pages should go in www:public_html/

Uploaded files for web pages should go in www:public_html/

Uploaded files for web pages should go in www:public_html/

Uploaded files for web pages should go in www:public_html/

Uploaded files for web pages should go in www:public_html/

I've moved them there now. 404-less.

Re: A0 versions with nice thinness

[identity profile] aardvark179.livejournal.com 2006-11-29 03:47 pm (UTC)(link)
:-)

I'll whack those through illustrator tonight and layout a coupe of test plots to see what works best when printed.

Re: A0 versions with nice thinness

[identity profile] aardvark179.livejournal.com 2006-12-04 11:53 am (UTC)(link)
Right I've got a nice printout of unholy if you're going to be around on Thursday, and the text is readable down to a remarkably small size. It's not perfectly central as it was printted on a 3 foot roll, but I'm sure you won't mind.

I could do even bigger, as we have a five foot wide roll on one of the plotters, but that start to become difficult to transport.

[identity profile] janetmk.livejournal.com 2006-11-28 10:47 am (UTC)(link)
That's very pleasing.