MRaster examples 22.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
working_orbits.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file working_orbits.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Working orbits.@EOL
7 @std C++20
8 @copyright
9 @parblock
10 Copyright (c) 1988-2015,2025, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
14 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
18
19 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
20 without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 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
27 DAMAGE.
28 @endparblock
29 @filedetails
30 @verbatim
31 magick \‍( working_orbits_oirt.tiff -evaluate Pow 0.5 \‍) \‍( working_orbits_ohst.tiff -evaluate Pow 0.5 \‍) \‍( working_orbits_ojmp.tiff -evaluate Pow 0.5 \‍) -combine working_orbits.png; nomacs working_orbits.png
32
33 magick \‍( working_orbits_ohst.tiff -evaluate Pow 0.3 \‍) ../docs/pics/cs/color_lut_docs_csCCfractal0RYBCW_50.png -clut working_orbits.png; nomacs working_orbits.png
34
35 magick \‍( working_orbits_ohst.tiff -evaluate Pow 0.3 -despeckle \‍) ../docs/pics/cs/color_lut_docs_csPLYinferno_50.png -clut working_orbits.png; nomacs working_orbits.png
36
37 Tricorn:
38 magick \‍( working_orbits_ohst.tiff -evaluate Pow 0.3 \‍) \‍( working_orbits_ihst.tiff -evaluate Pow 0.8 \‍) \‍( working_orbits_oirt.tiff -evaluate Pow 0.7 -despeckle -blur 10 \‍) -combine -rotate 90 working_orbits.png; nomacs working_orbits.png
39
40 @endverbatim
41*/
42/*******************************************************************************************************************************************************.H.E.**/
43/** @cond exj */
44
45//--------------------------------------------------------------------------------------------------------------------------------------------------------------
46#include "ramCanvas.hpp"
47#include "MRMathCPLX.hpp"
48
49//--------------------------------------------------------------------------------------------------------------------------------------------------------------
50typedef mjr::ramCanvas1c16b rcct;
51typedef mjr::ramCanvas3c8b rcrt;
52
53//--------------------------------------------------------------------------------------------------------------------------------------------------------------
54int main(void) {
55 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
56 const int csize = 7680/8;
57 const int maxitr = 256*4;
58 const double escRad = 5.0;
59 // const double z0r = 0.5;
60 // const double z0i = 0.0;
61 // const int resMul = 8;
62 // const double sweepXmin = -1.0;
63 // const double sweepXmax = 1.0;
64 // const int sweepXres = csize*resMul;
65 // const double sweepXdel = (sweepXmax-sweepXmin)/sweepXres;;
66 // const int sweepYres = csize*resMul;
67 // const double sweepYmin = -0.0;
68 // const double sweepYmax = 1.5;
69 // const double sweepYdel = (sweepYmax-sweepYmin)/sweepYres;
70 // const double drawXmin = -1.1;
71 // const double drawXmax = 1.1;
72 // const double drawYmin = -0.6;
73 // const double drawYmax = 1.6;
74
75 const double z0r = 0.0;
76 const double z0i = 0.0;
77 const int resMul = 8;
78 const double sweepXmin = -2.0;
79 const double sweepXmax = 2.0;
80 const int sweepXres = csize*resMul;
81 const double sweepXdel = (sweepXmax-sweepXmin)/sweepXres;;
82 const int sweepYres = csize*resMul;
83 const double sweepYmin = -2.0;
84 const double sweepYmax = 2.0;
85 const double sweepYdel = (sweepYmax-sweepYmin)/sweepYres;
86 const double drawXmin = -1.8;
87 const double drawXmax = 1.2;
88 const double drawYmin = -1.5;
89 const double drawYmax = 1.5;
90
91 rcct ihstRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Interior points histogram
92 rcct imagRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Interior points minimum distance to origin
93 rcct ohstRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points histogram
94 rcct oirtRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points max iteration for point
95 rcct ojmpRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points max jump to point
96 std::complex<double>* theOrbit = new std::complex<rcct::coordFltType>[maxitr+1];
97
98 for(int y=0;y<sweepYres;y++) {
99 if((y%(sweepYres/16))==0)
100 std::cout << "LINE: " << y << "/" << sweepYres << std::endl;
101 for(int x=0;x<sweepXres;x++) {
102 std::complex<rcct::coordFltType> c(x * sweepXdel + sweepXmin, y * sweepYdel + sweepYmin);
103 std::complex<rcct::coordFltType> z(z0r, z0i);
104 for(rcct::colorChanType count=0; ; count++) {
105 //z = mjr::math::cplx::rchs_if_ineg(z) * z * mjr::math::cplx::iabs(z) + c;
106 z = std::pow(std::conj(z), 2) + c ;
107 if(std::abs(z)>escRad) {
108 for(rcct::colorChanType i=10; i<=count; i++) {
109 ohstRamCanvas.incPxChan(theOrbit[i]);
110 oirtRamCanvas.tformPixel(theOrbit[i], [i](auto& c) { c.tfrmMax(i); });
111 rcct::colorChanType dst = static_cast<rcct::colorChanType>(std::abs(theOrbit[i]-theOrbit[i-1]) / escRad * rcct::colorType::maxChanVal);
112 ojmpRamCanvas.tformPixel(theOrbit[i], [dst](auto& c) { c.tfrmMax(dst); });
113 }
114 break;
115 } else if(count>=(maxitr-1)) {
116 for(rcct::colorChanType i=10; i<=count; i++) {
117 rcct::colorChanType dst = static_cast<rcct::colorChanType>(std::abs(theOrbit[i]) / escRad * rcct::colorType::maxChanVal);
118 imagRamCanvas.tformPixel(theOrbit[i], [dst](auto& c) { if(c.isBlack()) c.setC0(dst); else c.tfrmMin(dst); });
119 ihstRamCanvas.incPxChan(theOrbit[i]);
120 }
121 break;
122 }
123 theOrbit[count] = z;
124 }
125 }
126 }
127
128 // Dump out our "data" images
129 oirtRamCanvas.autoHistStrech();
130 oirtRamCanvas.writeTIFFfile("working_orbits_oirt.tiff");
131 ohstRamCanvas.autoHistStrech();
132 ohstRamCanvas.writeTIFFfile("working_orbits_ohst.tiff");
133 ihstRamCanvas.autoHistStrech();
134 ihstRamCanvas.writeTIFFfile("working_orbits_ihst.tiff");
135 ojmpRamCanvas.autoHistStrech();
136 ojmpRamCanvas.writeTIFFfile("working_orbits_ojmp.tiff");
137 imagRamCanvas.autoHistStrech();
138 imagRamCanvas.writeTIFFfile("working_orbits_imag.tiff");
139
140 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
141 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
142}
143/** @endcond */
int main(int argc, char *argv[])