在SciLab中平滑动画三种形状

时间:2017-02-03 18:58:48

标签: animation scilab

这个answer提供了一种在SciLab中制作流畅动画的好方法。我现在必须写一个连接到两个弦的身体的模拟(因此它的运动有一些额外的力)。

链接中的代码可以很好地渲染单个点的移动,不幸的是,我没有设法使用此方法制作点+两行的动画。如果有人好奇,我尝试使用此代码:

frametime=(tk-t0)/Nt//defining the waitnig time

plot(Y(1,1),Y(2,1),"o")//plotting the point
plot([0;Y(1,1)],[0;Y(2,1)],style=1)
plot([D;Y(1,1)],[0;Y(2,1)],style=1)//plotting the two initial lines
h1_compound = gce();
h_point=h1_compound.children
h_point.mark_size = 20;
h_point.mark_background = 2;
h_line1=h_compound.children
h_line2=h_compound.children
//h_axes = gca();
//h_axes.data_bounds = [0,-1;10,1];  
realtimeinit(frametime);
for i=1:Nt//my vectors have Nt points
  realtime(i);//wait "frametime" seconds before drawing the new position
  h_point.data=[Y(1,i),Y(2,i)];
  h_line1.data=[[0;Y(1,i)],[0;Y(2,i)]]
  h_line2.data=[[D;Y(1,i)],[0;Y(2,i)]]
end

问题是:有没有办法制作三种形状的动画而不会使轴闪烁(就像窗口刷新一样)或其他奇怪的东西?

1 个答案:

答案 0 :(得分:0)

由于您没有创建MCVE我无法重现您的确切问题。但您可以尝试在数据修改之前添加drawlater();,并在数据修改后添加drawnow();,以查看它是否对闪烁有帮助。

或者你可以通过xs2gif在每一轮保存你的情节来获得更好的结果,并用另一个gifmaker程序组装动画(有免费的在线网站可以做到这一点,但有一些限制)。如果您需要展示结果,无论如何都应该执行此步骤。