How to calculate line-length for fixed width koch fractal?

197 Views Asked by At

I am playing with fractals, and drawing them with Python turtle

I am using this rules to create l-string for my koch fractal:

begin: f
f -> f+f--f+f

In here, f means go forward by a fixed length, - means turn right for 60 degrees, + means turn right for 60 degrees.

What I am trying to do is, calculate the value of fixed length in order for final fractal to have the same width, regardless of level of complexity of my fractal.

I can use length or the string or number of recursion that is used to create l-string.

I have tried dividing a fixed number with length of string or diving it for length of string to the power 3 (don't ask why, I just tried if it would work).

Bonus Points: Can you show me how to generalize the solution for other types of fractals?

1

There are 1 best solutions below

0
On BEST ANSWER

The first four iterations.

An intuitive approach:

Take $f$ to be the fixed movement amount you refer to in your question. Observe the first four iterations of the fractal above (apologies for the slightly stretched image). Clearly, the width of the first iteration is your step length, $f$. It is also clear that the width of the second iteration is $3f$ (since the new "triangles" formed are equilateral). You can use this observation$-$that the four lines which replace each old line in successive iterations "span" three of your new $f-$ to easily also observe that the third iteration will be $9f$ wide and that the fourth iteration will be $27f$ wide. Since you understand this trend and why it is occurring, you can conclude that the general formula for the width of the $n$th iteration is $w=3^{n-1}f$. Since we want constant $w$ by modifying $f$ depending on $n$, we can rearrange to find $f$ as a function of $n$. We have $f(n)=\frac{w}{3^{n-1}}$. So, to maintain constant width, we must divide $f$ by 3 upon every successive iteration.