Code Monkey home page Code Monkey logo

fractal's Introduction


📜 About Project

A fractal is a fragmented geometrical figure that infinitely repeats at smaller scales.
So this project generates beautiful fractals from the complex numbers of an iterative mathematical construct.
For graphics, I used SFML library and NVIDIA CUDA Toolkit for parallel computing.
Project builds by CMake build system, so if you do not have CUDA Toolkit or your platform doesn't have CUDA support, CMake will build this project without CUDA support and computing will be done through CPU threads.
By default, there will be 40 parallel threads, the color is rgb(21, 0, 0) and the window size is 800px.

Note

If you want to change color, threads count, window size, or other defaults, change them in helpers.hpp file.

📑 Fractals List

The program supports these fractal sets:

Name Formula
Mandelbrot $z_{n+1} = z_n^2 + c, z_0 = 0$
Julia $z_{n+1} = z_n^2 + c, z_0 = c$
Burning Ship $z_{n+1} = abs(z_n^2) + c, z_0 = 0$
Tricorn $z_{n+1} = \overline{z_n}^2 + c, z_0 = 0$
Mandelbox It's more complex, see this article
Multibrot $z_{n+1} = z_n^d + c, z_0 = 0, d = 5$
Mandelbar Take a look at Mandelbar 5th (horizontal) in this image
Per. Burning Ship Take a look at Perpendicular Burning Ship in this image
Celtic Mandelbrot Take a look at Celtic Mandelbrot in this image

Useful Links:

https://www.deviantart.com/kosmic-stardust/art/Mandelbrot-ABS-Variations-Complete-Set-of-Formulas-487039852 https://www.deviantart.com/kosmic-stardust/art/4th-Order-ABS-Mandelbrot-Variations-Complete-Set-601300868 https://www.deviantart.com/kosmic-stardust/art/5th-Order-ABS-Mandelbrot-Variations-601484985

🎮 Controls

The program supports the following controls:

Key Description
ESC Close the program window
Keys [1-9] Move to another fractal
Key R Change the red component of fractal
Key G Change the green component of fractal
Key B Change the blue component of fractal
Mouse Scroll Zoom in and out of the fractal
⬆️ ⬇️ ⬅️ ➡️ Change the viewpoint
Key L Lock Julia's fractal
Zero Reset the fractal to its initial state

👨‍💻 Usage

Requirements

The program is written in C++ and thus needs the g++ compiler and some standard C++ libraries to run.
Also needs to install SFML library and CMake. If you want to use your NVIDIA GPU power, you need to install NVIDIA CUDA Toolkit.

Instructions

1. Compiling the program

To build the release version, run these commands:

$ cd path/to/fractal
$ mkdir Release
$ cd Release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make

To build the debug version, run these commands:

$ cd path/to/fractal
$ mkdir Debug
$ cd Debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
$ make

2. How to run the program

Run the executable too see the help message:

./fractal

Or run with some supported fractal:

./fractal mandelbrot

Note

For CUDA support, you need to install CMake version >= 3.24
If you want to disable CUDA support, just uncommnet line 19 in CMakeLists.txt file.

🌄 Screenshots

Mandelbrot

Fractal Mandelbrot Fractal Mandelbrot

Julia

Fractal Julia

Burning Ship

Fractal Burning Ship

Tricorn

Fractal Tricorn

Mandelbox

Fractal Mandelbox

Multibrot

Fractal Multibrot

Mandelbar

Fractal Mandelbar

Perpendicular Burning Ship

Fractal Perpendicular Burning Ship

Celtic Mandelbrot

Fractal Celtic Mandelbrot

fractal's People

Contributors

dpetrosy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.