70#include "ramCanvas.hpp"
71#include "MRMathCPP.hpp"
75 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
76 const bool CENTER =
true;
77 const int IMXSIZ = 7680/2;
78 const int IMYSIZ = 7680/2;
79 const double m1 = 1.0;
80 const double m2 = 1.0;
81 const double L1 = 1.0;
82 const double L2 = 1.0;
83 const int steps = 200;
84 const double h = 0.01;
85 const double g = 9.80665;
86 const double p = std::numbers::pi;
88 mjr::ramCanvas3c8b theRamCanvas(IMXSIZ, IMYSIZ);
90 theRamCanvas.newRealCoords(0, 2*p, 0, 2*p);
92 theRamCanvas.newRealCoords(-p, p, -p, p);
93 theRamCanvas.clrCanvasToBlack();
95# pragma omp parallel for schedule(static,1)
96 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
98 std::cout << y << std::endl;
99 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
100 double theta1 = theRamCanvas.int2realX(x);
102 double theta2 = theRamCanvas.int2realY(y);
104 for(
int i=0; i<steps; i++) {
105 double cd = cos(theta1-theta2);
106 double sd = sin(theta1-theta2);
107 double o12 = omega1*omega1;
108 double o22 = omega2*omega2;
109 double denom = 2*m1+m2-m2*cos(2*theta1-2*theta2);
110 double new_omega1 = (-g*(2*m1+m2)*sin(theta1)-m2*g*sin(theta1-2*theta2)-2*sd*m2*(o22*L2+o12*L1*cd))/(L1*denom);
111 double new_omega2 = (2*sd*(o12*L1*(m1+m2)+g*(m1+m2)*cos(theta1)+o22*L2*m2*cd))/(L2*denom);
113 omega1 += h*new_omega1;
115 omega2 += h*new_omega2;
117 double r = mjr::math::ivl::wrapCO(theta2, 2*p)/(2*p);
118 double b = mjr::math::ivl::wrapCO(theta1, 2*p)/(2*p);
119 double g = mjr::math::ivl::wrapCC((omega1+omega2)/(4*p), 1.0);
120 theRamCanvas.getPxColorRefNC(x, y).setChansRGB_dbl(r, g, b);
123 theRamCanvas.writeTIFFfile((CENTER ?
"doublePendulum_center.tiff" :
"doublePendulum_corner.tiff"));
124 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
125 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])