Mitch Richling: Tricorn Fractal
Author: | Mitch Richling |
Updated: | 2024-10-31 |
Table of Contents
1. Introduction
The Tricorn Fractal is another Mandelbrot'alike in that its generating function is a minor modification of the one used for the Mandelbrot Set:
We render Tricorn Fractals using the
2. Algorithms
#include "ramCanvas.hpp" int main(void) { std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now(); const int NUMITR = 1024; const int IMXSIZ = 7680/2; const int IMYSIZ = 7680/2; mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ, -2.75, 2.75, -2.75, 2.75); // The whole thing //mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ, -2.1, -0.30, -0.25, 0.25); // The "corn" //mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ, -1.65, -1.46, -0.07, 0.07); // Tiny tricorns & mandelbrots //mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ, -1.48-0.0065, -1.48+0.007, -0.0035, 0.0035); // That biggest mandelbrot-like set from above for(int y=0;y<theRamCanvas.getNumPixY();y++) { for(int x=0;x<theRamCanvas.getNumPixX();x++) { std::complex<double> c(theRamCanvas.int2realX(x), theRamCanvas.int2realY(y)); std::complex<double> z(0.0, 0.0); int count = 0; while((std::norm(z)<14) && (count<=NUMITR)) { z=std::pow(std::conj(z), 2) + c; count++; } if(count < NUMITR) theRamCanvas.drawPoint(x, y, mjr::ramCanvas3c8b::colorType::csCColdeFireRamp::c(static_cast<mjr::ramCanvas3c8b::csIntType>(count*30))); } } theRamCanvas.writeTIFFfile("tricorn.tiff"); std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime; std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl; }
The above program will generate the following image: