采用倍频动画轨迹 [英] Animate trajectory using Octave

查看:171
本文介绍了采用倍频动画轨迹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组描述一个物体的运动轨迹(X,Y)坐标。我想用GNU八度动画这一轨迹。

数据集是相当大的,所以我就不能在每次迭代重绘整个情节,如果我希望动画流畅。什么功能都没有,让我来更新的阴谋,而不是重绘?

另外,我有另一组(VX,VY)分,其中描述了物体的速度。我想我的动画轨迹把速度考虑在内。我应该使用什么功能,有计划睡了几毫秒才能使轨迹动画以相同的速度为对象?

(我已经知道有八音等功能彗星,但我需要写我自己的动画师。)


编辑:这是我有到现在为止。我预计今年跑的太快,并要求我使用暂停,但它仍然pretty慢( X 有10001元)。

 边界= [MIN(x)的最大值(X)分钟(Y)最大值(Y)];
轴(边界);等一下
对于k = 2:长度(x)的
    积(X(K-1:K)中,y(K-1:K));
    的DrawNow(揭发);
结束
推迟


解决方案

您可以使用设置命令来改变只是扩展数据 YDATA 一定情节对象数据 ^ h

  H =图(my_xdata(0),my_ydata(0))
为I_ = 1:长度(my_xdata)
    集(H,'YDATA',my_ydata(I_))
    集(H,'扩展数据,my_xdata(I_))
    暂停(开方(VX(我_)^ 2 + VY(我_)^ 2))
结束

暂停(X)命令暂停X 秒,可以小于1。

I have a set of (x,y) coordinates that describe the trajectory of an object. I'd like to animate this trajectory using GNU Octave.

The data set is quite large so I won't be able to redraw the entire plot at every iteration if I want the animation to be smooth. What functions are there that would allow me to "update" a plot rather than redraw it?

Also, I have another set of (vx,vy) points, which describe the speed of the object. I'd like my animated trajectory to take speed into account. What function should I use to have the program sleep for a couple of milliseconds as to make the trajectory animate at the same speed as the object?

(I already know Octave has functions such as comet, but I need to write my own animator.)


Edit: Here's what I have up until now. I expected this to run too fast and require me to use pause, but it's still pretty slow (x and y have 10001 elements).

bounds = [min(x) max(x) min(y) max(y)];
axis(bounds);

hold on
for k = 2 : length(x)
    plot(x(k-1:k), y(k-1:k));
    drawnow("expose");
end
hold off

解决方案

You can use the set command to change just the XData and YData data for a certain plot object h:

h = plot(my_xdata(0),my_ydata(0))
for i_=1:length(my_xdata)
    set(h, 'YData', my_ydata(i_))
    set(h, 'XData', my_xdata(i_))
    pause(sqrt(vx(i_)^2+vy(i_)^2))
end

The pause(x) command pauses for x seconds, which can be less than 1.

这篇关于采用倍频动画轨迹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆