The previous application built using the SDL library has been ported to OpenCV which provides a much more informative feedback. Particularly speaking, earlier the zooming action was accomplised by tracking the mouse movements through a callback to form an imaginary zooming region. But now using the OpenCV library the zooming action has been made more intutive and easy to use.
This Capstone Project is meant to show the students(here mine) ability to integrate what has been learned throughout C++ Nanodegree program. This project demonstrates that I can independently create applications using a wide range of C++ features.
The Mandelbrot set is the set of complex numbers c for which the function f(z) = z^2 + c
does not diverge when iterated from z = 0
, i.e., for which the sequence f(0)
, f(f(0))
, etc., remains bounded in absolute value.
This application enables investigating the Mandelbrot set flexibily and is capable of scaling to high precision investigation when proportional comutation power is availablle. This Repo consists of two versions of the same application-
- The first version maps each pixel to a point on the complex plane sequentially i.e. serial program execution. On branch serial_computation.
- The second version first divides the entire window into sub windows based on the supported hardware concurrenct and then maps each pixel in each sub window to the complex plane parallely to increase the speed. The increase in speed due to parallel execution is clearly evident during usage. On branch parallel_computation.
- cmake >= 3.7
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
- OpenCV 4.1
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./Mandelbrot
- The application window is capable of handling zoom requests with a visual feedback using OpenCV's selctROI feature
- To zoom, draw a rectangle by moving the left mouse key pressed from top left corner to bottom right corner. Press SPACE or ENTER when happy with the selection
- The drawn rectangle is turned into a square internally to maintain aspect ratio
- Depending on the window size initially set and the max iterations set, the window will be updated in less than a second or in a couple of seconds to show the slected complex plane region of the Mandelbrot set
- To quit press 'q' at the prompt when asked or when decided to proceed with zoom.
# z = z^(n) + c
# ./Application window_size maximum_iterations order_of_mandelbrot_set
$> ./Mandelbrot 600 600 6
You would be interested to know that the number of lobes in the Mandelbrot set are always 1 less than the order of the set.
Here is the output that can be seen in the window for a 6th order Mandelbrot set
It is possible that you might run into this error
undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
,
When this happens, remove the -std=c++17
flag from CMakeLists.txt file and run make
again. This should solve the strange error.
- kScreenDim - Display window dimension (the bigger this value is the more computations and hence possible to see some delay)
- maxIter - Maximum number of iterations to check if the points on complex plane cross the 2.0 threshold
- MandelbrotSetOrder - Determines the Mandelbrot set order to compute
z = std::pow(z, SET_ORDER) + c
Some of the core computing functions are adopted from this article https://solarianprogrammer.com/2013/02/28/mandelbrot-set-cpp-11/