41#include "ramCanvas.hpp"
44typedef mjr::ramCanvas3c8b rcT;
45typedef rcT::colorChanType rcccT;
49 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
51 double ZROEPS = .0001;
53 const int IMGSIZ = 7680;
54 std::complex<double> r1( 1.0, 0.0);
55 std::complex<double> r2(-0.5, sin(2*std::numbers::pi/3));
56 std::complex<double> r3(-0.5, -sin(2*std::numbers::pi/3));
57 rcT theRamCanvas(IMGSIZ, IMGSIZ, -2.15, 1.85, -2.0, 2.0);
59# pragma omp parallel for schedule(static,1)
60 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
61 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
62 std::complex<double> z = theRamCanvas.int2real(x, y);
63 double minMod1 = std::abs(z-r1);
64 double minMod2 = std::abs(z-r2);
65 double minMod3 = std::abs(z-r3);
66 for(
int count=0; count<MAXITR; count++) {
67 double modz = std::abs(z);
68 if ((modz>MAXZ) || (modz<ZROEPS))
70 z = z-(z*z*z-1.0)/(z*z*3.0);
71 if(std::abs(z-r1) < minMod1) minMod1 = std::abs(z-r1);
72 if(std::abs(z-r2) < minMod2) minMod2 = std::abs(z-r2);
73 if(std::abs(z-r3) < minMod3) minMod3 = std::abs(z-r3);
74 if ((modz<ZROEPS) || (minMod1<ZROEPS) || (minMod2<ZROEPS) || (minMod3<ZROEPS))
78 rcccT r =
static_cast<rcccT
>((minMod1 < std::min(minMod2, minMod3) ? 100.0 : 720.0*std::log(4.73-minMod1)));
79 rcccT g =
static_cast<rcccT
>((minMod2 < std::min(minMod1, minMod3) ? 100.0 : 720.0*std::log(4.73-minMod2)));
80 rcccT b =
static_cast<rcccT
>((minMod3 < std::min(minMod1, minMod2) ? 100.0 : 720.0*std::log(4.73-minMod3)));
81 theRamCanvas.drawPoint(x, y, rcT::colorType(r, g, b));
85 theRamCanvas.writeTIFFfile(
"newton_min_root.tiff");
86 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
87 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])