双摆动画

Double pendulum animation

我正在尝试获取动画双摆。虽然我可以获得任何(一个)质量的动画,但我无法同时获得两者。

restart; 
with(DEtools, odeadvisor); 
with(plots); 
with(plottools); 
Sys := [2*(diff(T1(t), t, t))+cos(T1(t)-T2(t))*(diff(T2(t), t, t))+sin(T1(t)-T2(t))*(diff(T2(t), t))^2+19.6*sin(T1(t)) = 0, diff(T2(t), t, t)+cos(T1(t)-T2(t))*(diff(T1(t), t, t))-sin(T1(t)-T2(t))*(diff(T1(t), t))+9.8*sin(T2(t)) = 0, T1(0) = 1, (D(T1))(0) = 0, T2(0) = 1, (D(T2))(0) = 1];
sol := dsolve(Sys, type = numeric, range = 0 .. 20, output = listprocedure);
odeplot(sol, [T1(t), T2(t)], 0 .. 20, refine = 1); 
TT1, TT2 := op(subs(sol, [T1(t), T2(t)])); 
f := proc (t) options operator, arrow; pointplot([cos(TT1(t)), sin(TT1(t))], color = blue, symbol = solidcircle, symbolsize = 25) end proc; 
p := proc (t) options operator, arrow; pointplot([cos(TT2(t)), sin(TT2(t))], color = red, symbol = solidcircle, symbolsize = 25) end proc;

如有任何帮助,我们将不胜感激。

您没有对您的方程用于模拟物理系统的方式提供任何解释,这没有帮助。

所以我对你的意图和你的模型做了一些猜测。如果我的猜测不对,请不要怪我。

restart;
with(plots):

Sys := [2*(diff(T1(t), t, t))+cos(T1(t)-T2(t))*(diff(T2(t), t, t))
    +sin(T1(t)-T2(t))*(diff(T2(t), t))^2+19.6*sin(T1(t)) = 0,
    diff(T2(t), t, t)+cos(T1(t)-T2(t))*(diff(T1(t), t, t))
    -sin(T1(t)-T2(t))*(diff(T1(t), t))+9.8*sin(T2(t)) = 0,
    T1(0) = 1, (D(T1))(0) = 0, T2(0) = 1, (D(T2))(0) = 1]:

sol := dsolve(Sys, numeric, range = 0 .. 20, output = listprocedure):

TT1, TT2 := op(subs(sol, [T1(t), T2(t)])):

fp := t -> plots:-display(
          pointplot([sin(TT1(t))+sin(TT2(t)), -cos(TT1(t))-cos(TT2(t))],
                    color = red, symbol = solidcircle, symbolsize = 25),
          pointplot([sin(TT1(t)), -cos(TT1(t))],
                    color = blue, symbol = solidcircle, symbolsize = 25),
          plottools:-line([0,0],[sin(TT1(t)), -cos(TT1(t))]),
          plottools:-line([sin(TT1(t)), -cos(TT1(t))],
                          [sin(TT1(t))+sin(TT2(t)), -cos(TT1(t))-cos(TT2(t))]),
          scaling=constrained
       ):

animate(fp, [t], t=0..10, frames=200);

不知道你要的是不是这种堆叠图,代表"both"群众的位置。不太清楚你的意思。

但也许关键是,如果您在 pointplot 调用中使用的双元素列表代表(位移)向量,那么您可以在第二个上获得 stacked/cumulative 效果通过按元素添加这两个向量来质量。这就是红点在我的动画中的位置。希望这将使您能够以自己选择的表示方式获得两个质量的累积效果。