|
| 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 |
| 9 | + @copyright |
| 10 | + @parblock |
| 11 | + Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved. |
| 12 | +
|
| 13 | + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
| 14 | +
|
| 15 | + 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. |
| 16 | +
|
| 17 | + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation |
| 18 | + and/or other materials provided with the distribution. |
| 19 | +
|
| 20 | + 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 |
| 21 | + without specific prior written permission. |
| 22 | +
|
| 23 | + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 25 | + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 | + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | + 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 |
| 28 | + DAMAGE. |
| 29 | + @endparblock |
| 30 | +*/ |
| 31 | +/*******************************************************************************************************************************************************.H.E.**/ |
| 32 | +/** @cond exj */ |
| 33 | + |
| 34 | +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 35 | +#include "ramCanvas.hpp" |
| 36 | + |
| 37 | +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 38 | +typedef mjr::ramCanvas3c8b::colorType ct; |
| 39 | + |
| 40 | +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 41 | +int main(void) { |
| 42 | + std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now(); |
| 43 | + const int WIDTH = 1920/2; |
| 44 | + const int HEIGHT = 1920/2; |
| 45 | + const int NUMITR = 40; |
| 46 | + const double MAXZ = 4.0; |
| 47 | + |
| 48 | + const int NUMFRM = 24*2; |
| 49 | + const double ANGMIN = 0.0; |
| 50 | + const double ANGMAX = std::numbers::pi*2; |
| 51 | + const double RADIUS = 0.06; |
| 52 | + |
| 53 | +# pragma omp parallel for schedule(static,1) |
| 54 | + for(int frame=0; frame<NUMFRM; frame++) { |
| 55 | +# pragma omp critical |
| 56 | + std::cout << "Frame: " << frame << std::endl; |
| 57 | + double angle = frame*(ANGMAX-ANGMIN)/NUMFRM+ANGMIN; |
| 58 | + |
| 59 | + const std::complex<double> c(-0.400000+RADIUS*std::cos(angle), 0.10000+RADIUS*std::sin(angle)); |
| 60 | + const std::complex<double> p(0.29550+RADIUS*std::cos(angle), 0.00000+RADIUS*std::sin(angle)); |
| 61 | + mjr::ramCanvas3c8b theRamCanvas(WIDTH, HEIGHT, -1.10, 1.10, -1.50, 1.50); |
| 62 | + |
| 63 | + for(int y=0;y<theRamCanvas.getNumPixY();y++) { |
| 64 | + for(int x=0;x<theRamCanvas.getNumPixX();x++) { |
| 65 | + std::complex<double> z1(theRamCanvas.int2realY(y), theRamCanvas.int2realX(x)); |
| 66 | + std::complex<double> z2(0.0, 0.0); |
| 67 | + int count = 0; |
| 68 | + while((std::norm(z1)<MAXZ) && (count<=NUMITR)) { |
| 69 | + std::complex<double> z = z1*z1+c+p*z2; |
| 70 | + z2 = z1; |
| 71 | + z1 = z; |
| 72 | + count++; |
| 73 | + } |
| 74 | + if ((count < NUMITR) && (count > 5)) |
| 75 | + theRamCanvas.drawPoint(x, y, ct::csCCfractal0RYBCW::c(static_cast<ct::csIntType>(std::log(count)*110))); |
| 76 | + } |
| 77 | + } |
| 78 | + theRamCanvas.writeTIFFfile("phoenixM2_" + mjr::fmtInt(frame, 2, '0') + ".tiff"); |
| 79 | +# pragma omp critical |
| 80 | + std::cout << "FRAME(" << frame << "): " << "DONE" << std::endl; |
| 81 | + } |
| 82 | + |
| 83 | + std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime; |
| 84 | + std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl; |
| 85 | +} |
| 86 | +/** @endcond */ |
0 commit comments