Skip to content

Latest commit

 

History

History
112 lines (65 loc) · 4.39 KB

README.md

File metadata and controls

112 lines (65 loc) · 4.39 KB

fract-ol

mandelbrot set

Mark: 105/100

fract-ol, a ring 2 project of the 42 Cursus, is one of the introductory projects for utilising a graphical library and creating a basic computer graphics program. Students had the choice between fract-ol, FdF and so_long. The graphical library is 42's own proprietary graphical library, MiniLibX.

The purpose of fract-ol was about creating graphically beautiful fractals. It delved into the notion of complex numbers, optimisation in graphics, and event handling.

Note

Currently, the project only works on MacOS, as I only imported the Mac versions of miniLibX.

Running the program

To compile and run the program, run the following commands:

# Make using the Makefile for openGL

make -f opengl_Makefile		# Creates the fract-ol executable with openGL

# If that doesn't work, use Makefile for swift

make re -f swift_Makefile	# Creates the fract-ol executable with swift

# Run the fract-ol executable

./fract-ol <parameters>

Tip

For the best performance, try compiling with openGL version of miniLibX first. If that fails, then try using the swift version.

Warning

You may find the program won't compile because of issues with miniLibX, independent of what version you try and use. If you can't solve the issue, message me and I'll guide you through it.

Note: The bonus 5 marks came from having cool colours. You'll notice I have a snippet of code commented out for both Mandelbrot and Julia where you can make the colours almost psychedelic, when you sub out for the current colours I use. Personally I like the shades of black and white, I think it looks cleaner, and very pleasing to the eye.

Program parameters

The parameters my program takes are as follows:

# Program parameters

./fractol <Set> <Option1> <Option2>

# Sets

'm'		# Mandelbrot Set

'j'		# Julia Set

# Options - If no options given, defaults to '0' '0'

<Option1>	# Real Part

<Option2>	# Imaginary Part

# e.g. ./fract-ol m

# e.g. ./fract-ol j 0.0065 .2

Note: Mandelbrot Set does not accept options.

Note: <Options> ONLY accept floats. Option 1 and Option 2 combine to form a complex number. For the best outputs keep the values > -2 and < 2.

Program Graphical Output

The Mandelbrot Set Image at the start of this documentation is the graphical output of my program for the command:

./fract-ol m

An example Julia Set Fractal:

./fract-ol j 0 .8

julia set

Tip

You can use your scroll wheel to scroll in and out of the image. It gets pretty laggy the further you zoom in though, as the program has to do increasingly more calculations.

Mathematical Theory

Essentially, the Mandelbrot set, is the behaviour of the iteration from 0 of the equation Zn + 1 = Zn2 + C. Where C is the complex number formed from its starting position on the complex plane. So the value of C changes as you move around the x and yi axis.

There are two potential results:

  1. The number gets arbitrarily large
  2. The number remains small, never exceeds 2 from the origin

Based on the result of the point when subbed into the equation, we assign it relevant colours, which gives us the stunning Mandelbrot fractal most people are familiar with.

The Julia Set, is similarly the behaviour of iteration from 0 of the same equation, however, the C remains constant, and instead we change the starting value of Z.

If you're interested in finding out more or just want to have a chat, reach out to me on my social links (I only really have LinkedIn or my email), or leave a comment :) I had a lot of fun with this project and would love to share my enthusiasm.

Plans for repository

  • Screenshots to this documentation of exmaple outputs
  • Add mouse position zoom management (bonus)
  • Add another fractal set (bonus)
  • Re-evaluate project with bonuses

Personal Note

I really enjoy mathematics, and personally find it quite beautiful, and this project was a perfect exmaple of this. Delving into the concept of complex numbers and their applications, as well as quadratics, was something I've missed since finishing school mathematics. I'm glad I chose this program, and got to create these works of art. Whilst quite complicated, once you understand what's happening it can be very satisfying to see the outputs.