39#include "ramCanvas.hpp"
47 int lastAvoidBackward;
54std::vector<ifs> ifsList {
55 { 10000000, 1000, 3, -1, -1, -1, 2.0, 1.10},
56 {100000000, 1000, 4, -1, 1, -1, 2.0, 1.10},
57 {100000000, 1000, 4, -1, 2, -1, 2.0, 1.10},
58 {100000000, 1000, 4, -1, -1, 1, 2.0, 1.10},
59 {100000000, 1000, 4, -1, -1, -1, 2.0, 1.10},
60 {100000000, 1000, 4, -1, -1, -1, 2.3, 1.10},
61 {100000000, 1000, 5, 1, 1, -1, 2.0, 1.10},
62 {100000000, 1000, 5, 2, 2, -1, 2.0, 1.10},
63 {100000000, 1000, 5, -1, 1, 1, 2.0, 0.75},
64 {100000000, 1000, 5, -1, 1, -1, 2.0, 1.10},
65 {100000000, 1000, 5, -1, 2, -1, 2.0, 1.10},
66 {100000000, 1000, 5, -1, -1, 1, 2.0, 0.84},
67 {100000000, 1000, 5, -1, -1, 1, 2.0, 1.10},
68 {100000000, 1000, 5, -1, -1, 1, 2.3, 0.70},
69 {100000000, 1000, 5, -1, -1, -1, 2.0, 1.10},
70 {100000000, 1000, 5, -1, -1, -1, 2.3, 1.10},
71 {100000000, 1000, 6, 2, 2, -1, 2.0, 1.10},
72 {100000000, 1000, 6, 3, 1, -1, 2.0, 1.10},
73 {100000000, 1000, 7, 1, -1, 1, 2.5, 0.65},
74 {100000000, 1000, 7, 2, -1, 1, 2.5, 0.65},
75 {100000000, 1000, 7, 3, 3, 1, 2.5, 0.65},
76 {100000000, 1000, 7, 3, -1, 1, 2.5, 0.65},
77 {100000000, 1000, 7, 5, 5, 1, 2.5, 0.65},
78 {100000000, 1000, 7, 5, -1, 1, 2.5, 0.65},
79 {100000000, 1000, 8, 1, 1, 1, 2.0, 0.75},
80 {100000000, 1000, 8, 1, 1, -1, 2.0, 1.01},
81 {100000000, 1000, 8, 2, 2, 1, 2.0, 0.94},
82 {100000000, 1000, 8, 3, 3, 1, 2.0, 0.94},
83 {100000000, 1000, 8, 5, 1, 1, 2.0, 0.94},
84 {100000000, 1000, 8, 5, 2, 1, 2.0, 0.94},
85 {100000000, 1000, 8, 5, 5, 1, 2.0, 0.94},
86 {100000000, 1000, 10, 1, 1, 1, 2.5, 0.57},
87 {100000000, 1000, 10, 1, 9, 1, 2.5, 0.65},
88 {100000000, 1000, 10, 2, 2, 1, 2.5, 0.65},
89 {100000000, 1000, 10, 3, 3, 1, 2.5, 0.65},
90 {100000000, 1000, 10, 4, 4, 1, 2.5, 0.65},
91 {100000000, 1000, 10, 5, 5, 1, 2.5, 0.65},
92 {100000000, 1000, 10, 6, 1, 1, 2.5, 0.65},
93 {100000000, 1000, 10, 6, 6, 1, 2.5, 0.65},
94 {100000000, 1000, 10, 7, 7, 1, 2.5, 0.65},
95 {100000000, 1000, 10, 8, 8, 1, 2.1, 0.87},
96 {100000000, 1000, 10, 8, 8, 1, 2.3, 0.74},
97 {100000000, 1000, 10, 8, 8, 1, 2.5, 0.65},
98 {100000000, 1000, 15, 5, 5, 1, 3.8, 0.36}
103 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
104 mjr::ramCanvas3c8b theRamCanvas(2160, 2160);
105 theRamCanvas.setDrawMode(mjr::ramCanvas3c8b::drawModeType::ADDCLAMP);
106 std::vector<mjr::ramCanvas3c8b::colorType> aColor{ mjr::ramCanvas3c8b::colorType(1, 1, 1)};
107 auto numCol = aColor.size();
109 std::random_device rd;
110 std::minstd_rand0 rEng(rd());
112 for(
auto &theIFS :ifsList) {
113 theRamCanvas.newRealCoords(-theIFS.radius, theIFS.radius, -theIFS.radius, theIFS.radius);
114 theRamCanvas.clrCanvasToBlack();
116 std::vector<std::complex<double>> points;
117 double curAngle = std::numbers::pi/2;
118 for(
int i=0; i<theIFS.numPts; i++) {
119 points.push_back(std::complex<double>{cos(curAngle), sin(curAngle)});
120 curAngle += 2*std::numbers::pi/theIFS.numPts;
123 std::complex<double> z{0.1, 0.2};
126 for(
int n=0;n<theIFS.itrMax;n++) {
127 std::minstd_rand0::result_type rn = rEng();
128 int rpi =
static_cast<int>(rn % theIFS.numPts);
129 while(((lastPoint !=-1) && (theIFS.lastAvoidLast !=-1) && (rpi==lastPoint)) ||
130 ((lastPoint !=-1) && (theIFS.lastAvoidBackward!=-1) && (rpi==(lastPoint+theIFS.lastAvoidBackward)%theIFS.numPts)) ||
131 ((lastPoint !=-1) && (theIFS.lastAvoidForward !=-1) && ((rpi+theIFS.lastAvoidForward)%theIFS.numPts==lastPoint))) {
133 rpi =
static_cast<int>(rn % theIFS.numPts);
136 z = (z+points[rpi])/theIFS.factor;
137 if(n > theIFS.itrToss)
138 theRamCanvas.drawPoint(z, aColor[rn%numCol]);
139 double curMag = std::abs(z);
143 std::cout <<
"max mag: " << maxMag << std::endl;
145 theRamCanvas.applyHomoPixTfrm(&mjr::ramCanvas3c8b::colorType::tfrmStdPow, 1.0/5.0);
147 std::ostringstream stringStream;
148 stringStream <<
"chaos_game";
149 stringStream <<
"," << theIFS.numPts;
150 stringStream <<
"," << theIFS.lastAvoidForward;
151 stringStream <<
"," << theIFS.lastAvoidBackward;
152 stringStream <<
"," << theIFS.lastAvoidLast;
153 stringStream <<
"," << theIFS.factor;
154 stringStream <<
".tiff";
155 theRamCanvas.writeTIFFfile(stringStream.str());
158 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
159 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])