44#include "ramCanvas.hpp"
48enum class whyStopMPO { OUTSET,
54const int CSIZE = 4096;
55double theValues[CSIZE][CSIZE];
57double ranges[3][4] = { { -2.0, 1.0, -1.5, 1.5 },
58 { -0.12, -0.03, -0.92, -0.81 },
59 { 0.0353469, 0.5353469, 0.1153845, 0.6153845 } };
63 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
64 const int MAXITR = 6000;
65 const double BALL = 10000000.0;
68 mjr::ramCanvas3c8b::colorType aColor;
69 mjr::ramCanvas3c8b theRamCanvas(CSIZE, CSIZE);
72 for(
int i=0; i<3; i++) {
74 theRamCanvas.newRealCoords(ranges[i][0], ranges[i][1], ranges[i][2], ranges[i][3]);
75 theRamCanvas.clrCanvasToBlack();
78 std::complex<double> z;
79 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
81 std::cout <<
" CASE: " << i <<
" LINE: " << y <<
"/" << CSIZE << std::endl;
82 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
84 double cr = theRamCanvas.int2realX(x);
85 double ci = theRamCanvas.int2realY(y);
86 std::complex<double> c(cr, ci);
87 double p = std::abs(c-0.25);
88 if((cr >= p-2.0*p*p+0.25) && std::abs(c+1.0) >= 0.25) {
90 for(count=0; ; count++) {
92 why = whyStopMPO::MAXCOUNT;
95 if(std::abs(z)>BALL) {
96 why = whyStopMPO::OUTSET;
102 why = whyStopMPO::INSET;
104 if(why == whyStopMPO::OUTSET) {
107 double zn = std::norm(z);
109 pot = 0.5*log(zn)/pow(2.0, count);
113 if(maxPot < pot) { maxPot = pot; }
114 if(minPot > pot) { minPot = pot; }
116 theValues[x][y] = -1;
121 std::cout <<
"MIN: " << minPot <<
" MAX:" << maxPot << std::endl;
127 std::cout <<
"TGA_1" << std::endl;
128 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
129 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
130 double pot=theValues[x][y];
133 pot=(0xffff-1)-pot*(0xffff-2)/(maxPot-minPot);
134 aColor.setRGBcmpGreyTGA16bit(
static_cast<uint16_t
>(pot));
138 theRamCanvas.drawPoint(x, y, aColor);
141 theRamCanvas.writeTGAfile(
"mandelbrot_potential_a_" + std::to_string(i) +
".tga");
145 std::cout <<
"TGA_2" << std::endl;
146 for(
int x=0;x<theRamCanvas.getNumPixX();x++)
147 for(
int y=0;y<theRamCanvas.getNumPixY();y++)
148 if(theValues[x][y] < 0)
149 theRamCanvas.drawPoint(x, y, aColor.setRGBcmpGreyTGA16bit(0xffff-1));
150 theRamCanvas.writeTGAfile(
"mandelbrot_potential_b_" + std::to_string(i) +
".tga");
154 std::cout <<
"RAW_2" << std::endl;
155 mjr::ramCanvas1c16b theRamCanvasG(CSIZE, CSIZE);
156 for(
int x=0;x<theRamCanvasG.getNumPixX();x++) {
157 for(
int y=0;y<theRamCanvasG.getNumPixY();y++) {
158 double pot=theValues[x][y];
161 pot=(0x8000-1)-pot*(0x8000-2)/(maxPot-minPot);
162 theRamCanvasG.drawPoint(x, y,
static_cast<mjr::ramCanvas1c16b::colorChanType
>(pot));
164 theRamCanvasG.drawPoint(x, y, 0x8000-1);
168 theRamCanvasG.writeRAWfile(
"mandelbrot_potential_" + std::to_string(i) +
".mrw");
169 theRamCanvasG.autoHistStrech();
170 theRamCanvasG.writeTIFFfile(
"mandelbrot_potential_" + std::to_string(i) +
".tiff");
172 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
173 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])