This commit is contained in:
Miloslav Ciz 2024-02-11 21:17:16 +01:00
parent be97db7fc4
commit a9b3ef862e
9 changed files with 1732 additions and 1674 deletions

View file

@ -2,6 +2,8 @@
Informally speaking fractal is a shape that's geometrically "infinitely complex" while being described in an extremely simple way, e.g. with a very simple formula or [algorithm](algorithm.md). Shapes found in the nature, such as trees, mountains or clouds, are often fractals. Fractals show self-similarity, i.e. when "zooming" into an ideal fractal we keep seeing it is composed, down to an infinitely small scale, of shapes that are similar to the shape of the whole fractal; e.g. the branches of a tree look like smaller versions of the whole tree etc.
TODO: brief history
Fractals are the [beauty](beauty.md) of mathematics that can easily be seen even by non-mathematicians, so are probably good as a motivational example in [math](math.md) education.
Fractal is formed by [iteratively](iteration.md) or [recursively](recursion.md) (repeatedly) applying its defining rule -- once we repeat the rule infinitely many times, we've got a perfect fractal. [In the real world](irl.md), of course, both in nature and in computing, the rule is just repeat many times as we can't repeat literally infinitely. The following is an example of how iteration of a rule creates a simple tree fractal; the rule being: *from each branch grow two smaller branches*.
@ -20,7 +22,7 @@ Fractal is formed by [iteratively](iteration.md) or [recursively](recursion.md)
iteration 0 iteration 1 iteration 2 iteration 3
```
Mathematically fractal is a shape whose [Hausdorff dimension](hausdorff_dimension.md) (the "scaling factor of the shape's mass") is non-integer. For example the [Sierpinski triangle](sierpinski_triangle.md) can normally be seen as a 1D or 2D shape, but its Hausdorff dimension is approx. 1.585 as if we scale it down twice, it decreases its "weight" three times (it becomes one of the three parts it is composed of); Hausdorff dimension is then calculated as log(3)/log(2) ~= 1.585.
Mathematically fractal is a shape whose [Hausdorff dimension](hausdorff_dimension.md) (the "scaling factor of the shape's mass") may be non-integer and is bigger than its [topological dimension](topological_dimension.md) (the "normal" dimension suh as 0 for a point, 1 for a line, 2 for a plane etc.). For example the [Sierpinski triangle](sierpinski_triangle.md) has a topological dimension 1 but Hausdorff dimension approx. 1.585 because if we scale it down twice, it decreases its "weight" three times (it becomes one of the three parts it is composed of); Hausdorff dimension is then calculated as log(3)/log(2) ~= 1.585.
[L-systems](l_system.md) are one possible way of creating fractals. They describe rules in form of a [formal grammar](grammar.md) which is used to generate a string of symbols that are subsequently interpreted as drawing commands (e.g. with [turtle graphics](turtle_graphics.md)) that render the fractal. The above shown tree can be described by an L-system. Among similar famous fractals are the [Koch snowflake](koch_snowflake.md) and [Sierpinski Triangle](sierpinski_triangle.md).
@ -50,7 +52,7 @@ Fractals can of course also exist in 3 and more dimensions so we can have also h
However, as shown by Code Parade (https://yewtu.be/watch?v=Pv26QAOcb6Q), complex fractals could be rendered even before the computer era using just a projector and camera that feeds back the picture to the camera. This is pretty neat, though it seems no one actually did it back then.
A nice FOSS program to interactively zoom into 2D fractals is e.g. [xaos](xaos.md).
A nice [FOSS](foss.md) program to interactively zoom into 2D fractals is e.g. [xaos](xaos.md).
3D fractals can be rendered with [ray marching](ray_marching.md) and so called *distance estimation*. This works similarly to classic [ray tracing](ray_tracing.md) but the rays are traced iteratively: we step along the ray and at each step use an estimate of the current point to the surface of the fractal; once we are "close enough" (below some specified threshold), we declare a hit and proceed as in normal ray tracing (we can render shadows, apply materials etc.). The distance estimate is done by some clever math.