Skip to content

This project is about creating graphically beautiful fractals.

Notifications You must be signed in to change notification settings

AnaVolkmann/42_FRACTOL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fract-ol

fract-ol_badge/

This repository contains the code for the Fract-ol project, including both mandatory and bonus parts.


Final score

fractol_grade/

The fract-ol project from the 42 School is one of the three "beginner" graphical projects of the cursus. It teaches you about manipulating a low-level graphic library, advanced math, and more.

fract-ol_opening/

What is a fractal?

A fractal is an infinitely complex pattern that repeats at different scales, created through a simple, recursive process. These patterns, often linked to chaos, exist between familiar dimensions. Fractals are common in nature, appearing in trees, rivers, coastlines, mountains, clouds, and hurricanes. Abstract fractals, like the Mandelbrot Set, can be generated by computers through repeated calculations of equations.

👨‍💻 Usage

Requirements

The program is written in C language and thus needs the gcc compiler and some standard C libraries to run. In addition to that, you will need the MinilibX library, of course.

Instructions

  • Clone the repository

     git clone https://github.com/AnaVolkmann/42_FRACTOL.g
  • To compile the program, run the following command

     make
  • To execute the program, use the following command

     ./fractol <fractal>

Available commands: mandelbrot, julia.

🎮Controls

The program supports the following controls:

Mouse Scroll Zoom
⬆️ ⬇️ ⬅️ ➡️ Move the view
SHIFT Shift the color range
- and + Decrease or increase the max iterations
SPACE Generate new constants for the Julia fractal
ESC Close the program window

🚀 The lower the iterations, the faster the program will run. 🐢 The deeper the zoom, the more iterations are needed to render the fractal, the slower the program.


📐The math behind fractals

Fractals are formed by mathematical suites.

For example, the Julia and Mandelbrot sets are defined by the following suite:

$$ z_{n+1} = z_n^2 + c $$

Fractals are based on complex numbers (i.e. numbers with a real and imaginary part, like $z = a + bi$).

  • The $a$ (real) part of the complex number is represented on a x-axis.

  • The $b$ (imaginary) part of the complex number is represented on a y-axis.

  • This means that the coordinates $(3, 7)$ represent number $z = 3 + 7i$, and that every pixel of a window can be used to represent a complex number.

  • Every complex number put into the suite will either:

    • converge to a finite number
    • diverge to infinity.
  • The pixels of the window can be colored depending on whether the complex number they represent converges or diverges.


🌌DEMONSTRATION

Mandelbrot

$z_{n+1} = z_n^2 + c$
fractoljulia/

Julia

$c_{real} = -0.835 and $c_{imaginary} = -0.2321

As the number of iterations increases, the fractal rendering becomes more defined and detailed.

Evolution shown by increasing iterations:

About 1.000 iterations
juliaset/
About 2.500 iterations
juliaset2/
About 4.000 iterations
juliaset3/
About 8.000 iterations
juliaset4/