MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
phoenixM2.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file phoenixM2.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Create a phoenix Julia set movie.@EOL
7 @std C++20
8 @see Writeup with images: https://www.mitchr.me/SS/phoenix/
9 @see MRaster repository: https://github.com/richmit/mraster/
10 @see Doxygen documentation: https://www.mitchr.me/SS/mraster/doc-examples/autodocs/html/
11 @see Related example: https://github.com/richmit/mraster/blob/master/examples/phoenix.cpp
12 @copyright
13 @parblock
14 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
15
16 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
17
18 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
19
20 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
21 and/or other materials provided with the distribution.
22
23 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
24 without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 DAMAGE.
32 @endparblock
33*/
34/*******************************************************************************************************************************************************.H.E.**/
35/** @cond exj */
36
37//--------------------------------------------------------------------------------------------------------------------------------------------------------------
38#include "ramCanvas.hpp"
39
40//--------------------------------------------------------------------------------------------------------------------------------------------------------------
41typedef mjr::ramCanvas3c8b::colorType ct;
42
43//--------------------------------------------------------------------------------------------------------------------------------------------------------------
44int main(void) {
45 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
46 const int WIDTH = 1920/2;
47 const int HEIGHT = 1920/2;
48 const int NUMITR = 40;
49 const double MAXZ = 4.0;
50
51 const int NUMFRM = 24*2;
52 const double ANGMIN = 0.0;
53 const double ANGMAX = std::numbers::pi*2;
54 const double RADIUS = 0.06;
55
56# pragma omp parallel for schedule(static,1)
57 for(int frame=0; frame<NUMFRM; frame++) {
58# pragma omp critical
59 std::cout << "Frame: " << frame << std::endl;
60 double angle = frame*(ANGMAX-ANGMIN)/NUMFRM+ANGMIN;
61
62 const std::complex<double> c(-0.400000+RADIUS*std::cos(angle), 0.10000+RADIUS*std::sin(angle));
63 const std::complex<double> p(0.29550+RADIUS*std::cos(angle), 0.00000+RADIUS*std::sin(angle));
64 mjr::ramCanvas3c8b theRamCanvas(WIDTH, HEIGHT, -1.10, 1.10, -1.50, 1.50);
65
66 for(int y=0;y<theRamCanvas.getNumPixY();y++) {
67 for(int x=0;x<theRamCanvas.getNumPixX();x++) {
68 std::complex<double> z1(theRamCanvas.int2realY(y), theRamCanvas.int2realX(x));
69 std::complex<double> z2(0.0, 0.0);
70 int count = 0;
71 while((std::norm(z1)<MAXZ) && (count<=NUMITR)) {
72 std::complex<double> z = z1*z1+c+p*z2;
73 z2 = z1;
74 z1 = z;
75 count++;
76 }
77 if ((count < NUMITR) && (count > 5))
78 theRamCanvas.drawPoint(x, y, ct::csCCfractal0RYBCW::c(static_cast<ct::csIntType>(std::log(count)*110)));
79 }
80 }
81 theRamCanvas.writeTIFFfile("phoenixM2_" + mjr::math::str::fmt_int(frame, 2, '0') + ".tiff");
82# pragma omp critical
83 std::cout << "FRAME(" << frame << "): " << "DONE" << std::endl;
84 }
85
86 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
87 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
88}
89/** @endcond */
int main(int argc, char *argv[])