MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
tinkerbell_search.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file tinkerbell_search.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Find parameters for tinkerbell fractals.@EOL
7 @std C++20
8 @see https://www.mitchr.me/SS/barrymartin/index.html
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//--------------------------------------------------------------------------------------------------------------------------------------------------------------
38int main(void) {
39 const int BSIZ = 480*8;
40
41 std::random_device rd;
42 std::mt19937 rEng(rd());
43 std::uniform_real_distribution<double> uniform_dist_double(-2.0, 2.0);
44
45 mjr::ramCanvas1c16b theRamCanvas(BSIZ, BSIZ, -2, 2, -2, 2); // Just used for coordinate conversion. ;)
46 mjr::ramCanvas1c16b::colorType aColor;
47 aColor.setChans(1);
48
49 for(int j=0; j<1000; j++) {
50 std::map<uint64_t, uint64_t> ptcnt;
51 double a = uniform_dist_double(rEng);
52 double b = uniform_dist_double(rEng);
53 double c = uniform_dist_double(rEng);
54 double d = uniform_dist_double(rEng);
55 double x = 0.1;
56 double y = 0.1;
57 double xMax = x;
58 double yMax = y;
59 double xMin = x;
60 double yMin = y;
61 uint64_t maxII = 0;
62 uint64_t inCnt = 0;
63 uint64_t itr;
64 for(itr=1;itr<10000000;itr++) {
65 double xNew = x*x-y*y+a*x+b*y;
66 double yNew = 2*x*y+c*x+d*y;
67 if (xNew > xMax) xMax = xNew;
68 if (xNew < xMin) xMin = xNew;
69 if (yNew > yMax) yMax = yNew;
70 if (yNew < yMin) yMin = yNew;
71 if ( !theRamCanvas.isCliped(x, y)) {
72 inCnt++;
73 theRamCanvas.drawPoint(x, y, theRamCanvas.getPxColor(x, y).tfrmAdd(aColor));
74 if(theRamCanvas.getPxColor(x, y).getC0() > maxII) {
75 maxII = theRamCanvas.getPxColor(x, y).getC0();
76 if(maxII > 16384) { // 1/4 of max possible intensity
77 break;
78 }
79 }
80 }
81 x=xNew;
82 y=yNew;
83 }
84 if ( (inCnt > 1000000) && (xMin < xMax) && (yMin < yMax) ) {
85 mjr::ramCanvas1c16b::coordIntType uCnt = theRamCanvas.statNumNonZeroPixels();
86 if (uCnt > 500000) {
87 std::cout << " { " << a << ", " << b << ", " << c << ", " << d << ", " << 0.1 << ", " << 0.1 << ", " << "1e8, " << xMin << ", " << xMax << ", " << yMin << ", " << yMax << " }, // " << " INC: " << inCnt << " UNQ: " << uCnt << std::endl;
88 }
89 }
90 }
91 return 0;
92}
93/** @endcond */
int main(int argc, char *argv[])