Skip to content

zelhajou/42-fractol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ascii-text-art

Description

Fract-ol is a computer graphics exploration project centered around the beauty and complexity of fractals. Using the C programming language and the MiniLibX library, this project aims to render stunning visual representations of the Julia and Mandelbrot fractal sets. It serves as a practical application of complex numbers, computer graphics optimization, and event handling in graphics programming.

Installation

To install Fract'ol, clone the repository and compile the source code using the provided Makefile.

git clone [repository-link]
cd fractol
make

Ensure that the MiniLibX library is installed on your system before compiling.

Usage

Run the program with the following command:

./fractol [fractal-type]

Replace [fractal-type] with either 1 Mandelbrot or 2 Julia to view the respective fractal set.

Screenshot

Mandelbrot sets

Screen Shot 2023-12-29 at 4 09 18 PM

Julia sets

Julia set for fc, c = −0.7269 + 0.1889i
Julia Set -0.7269 + 0.1889i
Julia set for fc, c = (φ − 2) + (φ − 1)i = −0.4 + 0.6i
Julia Set -0.4 + 0.6i
Julia set for fc, c = 0.35 + 0.35i
Julia Set 0.35 + 0.35i
Julia set for fc, c = 0.285 + 0.01i
Julia Set 0.285 + 0.01i
Julia set for fc, c = −0.8 + 0.156i
Julia Set -0.8 + 0.156i
Julia set for fc, c = 0.4 + 0.4i
Julia Set 0.4 + 0.4i
Julia set for fc, c = −0.835 − 0.2321i
Julia Set -0.835 - 0.2321i
Julia set for fc, c = 0.285 + 0i
Julia Set 0.285 + 0i

Explanation

In mathematics, there are many different types of geometry, each exploring shapes and dimensions in unique ways. Among these, fractal geometry is one of the most intriguing.

Fractal Geometry deals with shapes that look similar at any scale. This means that if you look at a small part of the shape, you will find it resembles the entire shape. Imagine a tree, where the smaller branches branch out in a way that mimics the whole tree. Fractals are not just beautiful drawings; they are crucial in science and mathematics to understand complex patterns in nature.

Screen Shot 2023-12-29 at 4 09 18 PM

Among the most famous fractal sets are the Julia and Mandelbrot sets:

  • Julia Set: Known for its complexity and beauty, it consists of points that generate complex fractal shapes when certain mathematical operations are applied to them.
  • Mandelbrot Set: Recognized for its distinctive shape, it is a complex example of fractals, representing a set of points in the mathematical space that exhibit repeating patterns when magnified.

Set

Set is a collection of elements with a common defined property.

In most sets, some numbers are included while others are excluded.
Consider the set of even numbers: S = {...,-2,0,2,4,6,...}, negative numbers: S = {...,-3,-2,-1,-1,-1/2,-1/4,...}

Mandelbrot Set:

The set of all numbers (c) for which the sequence Z_n remains small according to this formula:
Screen Shot 2023-12-29 at 4 09 18 PM
Screen Shot 2023-12-29 at 4 09 18 PM

Example 1: Is the number 1 part of the set? c = 1

Untitled.project.mp4

Is Z staying small: NO its getting big its getting very fast so is the number 1 part of the Mandelbrot set. answer is NO

Example 2: Is the number -1 part of the set? c = -1

Untitled.project.mp4

The Mandelbrot set also includes the complex and imaginary numbers

[+]² = [+]
[-]² = [+]
0² = 0

[i]² = [-] : not positive not negative and not zero : that's an imaginary number

https://plus.maths.org/content/what-mandelbrot-set

Complex Numbers

Complex Numbers are numbers that combine real and imaginary parts. A complex number is written as a + bi, where:

  • a is the real part.
  • bi is an imaginary part.
  • i is the imaginary unit, defined as the square root of -1, so i^2 = -1.

complex-plane-3-4i

https://www.mathsisfun.com/numbers/complex-numbers.html

Screen Shot 2023-12-31 at 3 31 04 AM Screen Shot 2023-12-31 at 3 32 49 AM
Screen Shot 2023-12-31 at 3 41 21 AM
  • Black: belnog to the mandelbrot set
  • Color: they dont
    • Shade: if the sequence of Z gets really big really fast
    • brighter: if Z gets big but it does so slowly

Calculating the Julia and Mandelbrot Sets

Mandelbrot Set:

  1. Choose a complex number c.
  2. Start with z_0 = 0.
  3. Repeatedly apply the formula: z_{n+1} = z_n^2 + c.
  4. If the magnitude of z_n (|z_n|) remains less than or equal to 2 after many iterations, then c is part of the Mandelbrot set.
  5. If |z_n| exceeds 2 at any step, c is not part of the Mandelbrot set.

https://www.geogebra.org/m/jcpvtkhz

Julia Set Calculation:

  1. Choose a fixed complex number c.
  2. Choose z_0 as your starting point.
  3. Repeatedly apply the formula: z_{n+1} = z_n^2 + c.
  4. If the magnitude of z_n (|z_n|) stays less than or equal to 2 after many iterations, then z_0 is part of the Julia set.
  5. If |z_n| exceeds 2, z_0 is not part of the Julia set.

Note: In these formulas, z_n and c are complex numbers, and z_{n+1} represents the complex number obtained after applying the formula to z_n.

Screen Shot 2023-12-29 at 4 09 18 PM

Resources

Learn about Fractals

Youtube:


3Blue1Brown :



Others:

Understand MiniLibX

42 Docs:


Github Library:


Gitbook


Resources:

Video:

github explination: https://github.com/suspectedoceano/mlx/tree/main/mlx_explained

video blog : https://medium.com/@jalal92/understanding-the-minilibx-a-practical-dive-into-x-window-programming-api-in-c-cb8a6f72bec3

video resources:

Render Julia and Mandelbrot Sets

Resources :

video:

About

Renders Julia and Mandelbrot fractals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published