43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
Fractals | Mandelbrot Fractal
|
|
|
|
Hello everybody and welcome. Today we are going to implement the
|
|
Mandelbrot fractal. I will also show you how to implement zooming and
|
|
camera movements.
|
|
|
|
I am going to use D programming language and Raylib graphics library. But
|
|
I will upload the C version as well. The intrinsic logic is identical
|
|
though. So, you shouldn't have any problems following me in a language
|
|
of your choice.
|
|
|
|
I have already created a new project. All it does at the moment is open
|
|
an empty window.
|
|
|
|
Mandelbrot fractal is basically a set of complex numbers, which are
|
|
constructed on a complex plane and which we will visualize in a 2D plane. As
|
|
a result, we get this amazing pattern.
|
|
|
|
So, how does it work? If you do some research you will find that Mandelbrot
|
|
set is a simple function of the form f(x) = z^2 + c, which we iterate
|
|
through starting from z = 0, where c is complex number that I will explain in
|
|
a moment.
|
|
|
|
The idea behind it is simple. We iterate throught the function and check
|
|
whether it's value vanishes at infinity. And then we draw each pixel based off
|
|
the result.
|
|
|
|
Here is an example:
|
|
|
|
|
|
// onto coding
|
|
Firstly, we need to create some
|
|
preliminary variables.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|