47#include "ramCanvas.hpp"
48#include "MRMathCPP.hpp"
52 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
53 const bool CENTER =
false;
54 const int NUMFRM = 1080;
55 const int IMXSIZ = 7680/8;
56 const int IMYSIZ = 7680/8;
57 const double m1 = 1.0;
58 const double m2 = 1.0;
59 const double L1 = 1.0;
60 const double L2 = 1.0;
61 const double h = 0.01;
62 const double g = 9.80665;
63 const double p = std::numbers::pi;
65 mjr::ramCanvas1c64F theta1canvas(IMXSIZ, IMYSIZ);
66 mjr::ramCanvas1c64F omega1canvas(IMXSIZ, IMYSIZ);
67 mjr::ramCanvas1c64F theta2canvas(IMXSIZ, IMYSIZ);
68 mjr::ramCanvas1c64F omega2canvas(IMXSIZ, IMYSIZ);
70 mjr::ramCanvas3c8b pcolorCanvas(IMXSIZ, IMYSIZ);
72 pcolorCanvas.newRealCoords(0, 2*p, 0, 2*p);
74 pcolorCanvas.newRealCoords(-p, p, -p, p);
75 pcolorCanvas.clrCanvasToBlack();
77 for(
int frame=0; frame<NUMFRM; frame++) {
78# pragma omp parallel for schedule(static,1)
79 for(
int y=0;y<pcolorCanvas.getNumPixY();y++) {
80 for(
int x=0;x<pcolorCanvas.getNumPixX();x++) {
81 double theta1, omega1, theta2, omega2;
83 theta1 = pcolorCanvas.int2realX(x);
85 theta2 = pcolorCanvas.int2realY(y);
88 theta1 = theta1canvas.getPxColorRefNC(x, y).getC0();
89 omega1 = omega1canvas.getPxColorRefNC(x, y).getC0();
90 theta2 = theta2canvas.getPxColorRefNC(x, y).getC0();
91 omega2 = omega2canvas.getPxColorRefNC(x, y).getC0();
92 double cd = cos(theta1-theta2);
93 double sd = sin(theta1-theta2);
94 double o12 = omega1*omega1;
95 double o22 = omega2*omega2;
96 double denom = 2*m1+m2-m2*cos(2*theta1-2*theta2);
97 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);
98 double new_omega2 = (2*sd*(o12*L1*(m1+m2)+g*(m1+m2)*cos(theta1)+o22*L2*m2*cd))/(L2*denom);
100 omega1 += h*new_omega1;
102 omega2 += h*new_omega2;
104 theta1canvas.drawPoint(x, y, theta1);
105 omega1canvas.drawPoint(x, y, omega1);
106 theta2canvas.drawPoint(x, y, theta2);
107 omega2canvas.drawPoint(x, y, omega2);
108 double r = mjr::math::ivl::wrapCO(theta2, 2*p)/(2*p);
109 double b = mjr::math::ivl::wrapCO(theta1, 2*p)/(2*p);
110 double g = mjr::math::ivl::wrapCC((omega1+omega2)/(4*p), 1.0);
111 pcolorCanvas.getPxColorRefNC(x, y).setChansRGB_dbl(r, g, b);
114 pcolorCanvas.writeTIFFfile((CENTER ?
"doublePendulumM_center_" :
"doublePendulumM_corner_") + mjr::math::str::fmt_int(frame, 4,
'0') +
".tiff");
116 std::cout <<
"FRAME(" << frame <<
"): " <<
"DONE" << std::endl;
118 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
119 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])