
Trigonometry And Making Curves
All of these curves are approximations really, assuming that the original goal was a circle. Even in the simple 8 sided case you run into problems in length. If the perpendicular sides were 4 units long, I think most people would do the 45 degree sides as being 4 up and 4 along. Applying pythagoras' theorem to this you'll find that the angled sides are root two times longer than the non 45 degree sides.
A closer approximation would be to go 3 up and 3 along, as this would give these sides length (root 18), as opposed to the other sides with length (root 16). The problem with this is it's not good for tiling textures.
When you move up to larger numbers things get more complicated. The general way to work out a circle of 4n subdivisions would be to fine 90/n, and then find tan 90/n, tan 180/n and so on. Then you find ratios of lengths that approximate each of these. As it happens, tan 45 = 1, so you can do that exactly. Tan 30 is 1/(root 3), which we approximate to 1/2, then use the 2:1 ratio. This is a pretty good approximation, which is why the 8 and 12 subidivision are so popular. You'll probably notice though that if you are aligning textures to the side, rotating 30 degrees will probably look wrong. arctan is the inverse of tan, and arctan 0.5 = 26.56, so 27 degrees will look better.
So how would we move up to 16, well, we need tan 15, tan 30 and tan 45, the rest are done by symmetry. Tan 15 is 0.268 to 3 dp, which isn't far off 1/4, so the ratio 1:4 is a good one(which I've just seen in the picture you posted...).
So, that's the ratio for the side on the inside/outside of the curve, how do we get the angles of the sides between the brushes? Well, it's a bit harder. The nicest appearance comes from taking the average of the angles of each pair of brushes and finding tan of that. So if the sides were 30 and 60, you'd do an angle of 45 between them, which is exactly what you do in the 12 sided case. Quite a bit harder to do this on the 16 case. tan 7.5 = 0.132, which is probably best to approximate with 1/8. tan 22.5 = 0.414, so 2/5? 1/2? Neither seem that appealing, the former is a wierd ratio, the latter will look quite distorted.
For those interested in maths, there's a rather neat way to get the best "simpler" fraction from a more complicated one, by using continued fractions. You can read how to calculate continued fractions at the wikipedia article:
http://en.wikipedia.org/wiki/Continued_fraction
For any given fraction, if you take the continued fraction form, knock off the fraction at the very "bottom" of the representation, then recalculate what you get, you'll get a simpler fraction that's a good approximation to the last one.
As an example
0.414 = 414/1000
= 1 / (2 + 172 / 414)
= 1 / (2 + 1 / (2 + 70/172))
= 1 / (2 + 1 / (2 + 1/ (2 + 32/70)))
= 1 / (2 + 1 / (2 + 1/ (2 + 1 / (2 + 3/16)))
=1/(2+1/(2+1/(2+1/(2+1/(5+1/3))))
So the best approximations are in order:
17/41
5/12
3/7
2/5
1/2
Not bad guesses then : - ).
Ok, facinating maths tangents aside, the last problem is how to do the ratios of different sides relative to each other, which comes back to the problem at the start with pythagoras. Basicallly just chosing a base size like 64 and always making the longer of the two sides this length is probably the easiest way, and has the benefit of being easy to texture. To be fair, the 45 degree example is a bit unfair, as it's the angle most prone to this problem, for all other sides the difference will be of a factor between 1 and root 2.