39#include "ramCanvas.hpp"
42typedef mjr::ramCanvas3c8b rcT;
43typedef rcT::colorChanType rcccT;
47 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
48 constexpr int MAXITR = 255;
49 constexpr double ZROEPS = .0001;
50 constexpr int IMGSIZ = 7680;
51 std::complex<double> r1( 1.0, 0.0);
52 std::complex<double> r2(-0.5, sin(2*std::numbers::pi/3));
53 std::complex<double> r3(-0.5, -sin(2*std::numbers::pi/3));
54 rcT theRamCanvas(IMGSIZ, IMGSIZ, -2.15, 1.85, -2.0, 2.0);
56# pragma omp parallel for schedule(static,1)
57 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
58 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
59 std::complex<double> z = theRamCanvas.int2real(x, y);
60 std::complex<double> zL = z;
61 double maxStepBack1 = 0.0;
62 double maxStepBack2 = 0.0;
63 double maxStepBack3 = 0.0;
64 double curRootMod1 = 1.0;
65 double curRootMod2 = 1.0;
66 double curRootMod3 = 1.0;
67 for(
int count=0; count<MAXITR; count++) {
68 double modz = std::abs(z);
71 z = z-(z*z*z-1.0)/(z*z*3.0);
72 curRootMod1 = std::abs(z-r1);
73 curRootMod2 = std::abs(z-r2);
74 curRootMod3 = std::abs(z-r3);
75 double curStepBack1 = curRootMod1 - std::abs(zL-r1);
76 double curStepBack2 = curRootMod2 - std::abs(zL-r2);
77 double curStepBack3 = curRootMod3 - std::abs(zL-r3);
78 if(curStepBack1 > maxStepBack1) maxStepBack1 = curStepBack1;
79 if(curStepBack2 > maxStepBack2) maxStepBack2 = curStepBack2;
80 if(curStepBack3 > maxStepBack3) maxStepBack3 = curStepBack3;
81 if ((modz<ZROEPS) || (curRootMod1<ZROEPS) || (curRootMod2<ZROEPS) || (curRootMod3<ZROEPS))
85 rcccT r =
static_cast<rcccT
>(( ((curRootMod1 < 2*ZROEPS) && (maxStepBack1 > 0)) ? std::log(1+maxStepBack1)*18 : 0));
86 rcccT g =
static_cast<rcccT
>(( ((curRootMod2 < 2*ZROEPS) && (maxStepBack2 > 0)) ? std::log(1+maxStepBack2)*18 : 0));
87 rcccT b =
static_cast<rcccT
>(( ((curRootMod3 < 2*ZROEPS) && (maxStepBack3 > 0)) ? std::log(1+maxStepBack3)*18 : 0));
88 theRamCanvas.drawPoint(x, y, rcT::colorType(r, g, b));
91 theRamCanvas.autoMaxHistStrechRGB();
92 theRamCanvas.applyHomoPixTfrm(&rcT::colorType::tfrmPow, 0.4);
93 theRamCanvas.writeTIFFfile(
"newton_max_back.tiff");
94 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
95 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])