I have three Euler-Lagrange equations which describe the dynamics of a triple pendulum and I have managed to plot the pendulum's pivot points parametically but I cannot figure out how to put arms on the pendulum and make the plot look more realistic.
EDIT: Here is the full code.
Subscript[x, 1] = Subscript[l, 1] Sin[ Subscript[\[Theta], 1][t]];
Subscript[y, 1] = -Subscript[l, 1] Cos[Subscript[\[Theta], 1][t]];
Subscript[x, 2] =
Subscript[l, 1] Sin[ Subscript[\[Theta], 1][t]] +
Subscript[l, 2] Sin[ Subscript[\[Theta], 2][t]];
Subscript[y,
2] = -Subscript[l, 1] Cos[Subscript[\[Theta], 1][t]] -
Subscript[l, 2] Cos[Subscript[\[Theta], 2][t]];
Subscript[x, 3] =
Subscript[l, 1] Sin[Subscript[\[Theta], 1][t]] +
Subscript[l, 2] Sin[Subscript[\[Theta], 2][t]] +
Subscript[l, 3] Sin[Subscript[\[Theta], 3][t]];
Subscript[y,
3] = -Subscript[l, 1] Cos[Subscript[\[Theta], 1][t]] -
Subscript[l, 2] Cos[Subscript[\[Theta], 2][t]] -
Subscript[l, 3] Cos[Subscript[\[Theta], 3][t]];
K = 0.5 Subscript[m,
1] (D[Subscript[x, 1], t]^2 + D[Subscript[y, 1], t]^2) +
0.5 Subscript[m,
2] (D[Subscript[x, 2], t]^2 + D[Subscript[y, 2], t]^2) +
0.5 Subscript[m,
3] (D[Subscript[x, 3], t]^2 + D[Subscript[y, 3], t]^2);
V = g (Subscript[m, 1] Subscript[y, 1] +
Subscript[m, 2] Subscript[y, 2] +
Subscript[m, 3] Subscript[y, 3]);
L = K - V;
Partial1 = D[L, Subscript[\[Theta], 1][t]];
Partial2 = D[L, Subscript[\[Theta], 2][t]];
Partial3 = D[L, Subscript[\[Theta], 1]'[t]];
Partial4 = D[L, Subscript[\[Theta], 2]'[t]];
Partial5 = D[L, Subscript[\[Theta], 3][t]];
Partial6 = D[L, Subscript[\[Theta], 3]'[t]];
EulerLagrange1 = 0 == FullSimplify[Partial1 - D[Partial3, t]];
EulerLagrange2 = 0 == FullSimplify[Partial2 - D[Partial4, t]];
EulerLagrange3 = 0 == FullSimplify[Partial5 - D[Partial6, t]];
Subscript[m, 1] = 1;
Subscript[m, 2] = 1;
Subscript[m, 3] = 1;
g = 1;
Subscript[l, 1] = 1;
Subscript[l, 2] = 1;
Subscript[l, 3] = 1;
timelimit = 6;
Subscript[initial\[Theta], 1] = Pi/2;
Subscript[initial\[Theta], 2] = 0;
Subscript[initial\[Theta], 3] = Pi/3;
solution =
NDSolve[{EulerLagrange1, EulerLagrange2, EulerLagrange3,
Subscript[\[Theta], 1][0] == Subscript[initial\[Theta], 1],
Subscript[\[Theta], 2][0] == Subscript[initial\[Theta], 2],
Subscript[\[Theta], 3][0] == Subscript[initial\[Theta], 3],
Subscript[\[Theta], 1]'[0] == 0, Subscript[\[Theta], 2]'[0] == 0,
Subscript[\[Theta], 3]'[0] == 0}, {Subscript[\[Theta], 1],
Subscript[\[Theta], 2], Subscript[\[Theta], 3]}, {t, 0,
timelimit}];
Animate[ParametricPlot[{{Subscript[x, 1], Subscript[y,
1]}, {Subscript[x, 2], Subscript[y, 2]}, {Subscript[x, 3],
Subscript[y, 3]}} /. solution, {t, 0, tend},
PlotRange -> {{-4, 4}, {-4, 4}}, AxesLabel -> {"x (m)", "y (m)"},
PlotLabel -> "Pendulum trajectory"], {tend, 0, timelimit},
AnimationRepetitions -> 1]
I am trying to make it look like this GIF which was posted as a comment: https://www.12000.org/animation/pendulum/movie.gif
Apologies for the messy post, this is my first time using Mathematica and the first time I have used this forum.
My post is mostly code now so I need to add details.
Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details. Details.
Subscripts
$\endgroup$