Lissajous曲线动画演示

[复制链接]
1120|5
 楼主| gaoyang9992006 发表于 2019-2-9 10:16 | 显示全部楼层 |阅读模式
  1. %% Animation demo for Lissajous curve
  2. close all;clear;clc;

  3. %%
  4. % Create a new figure window,
  5. % Background color is white
  6. % MenuBar is hidden
  7. % Image size is 480*480
  8. figure('Color','w','MenuBar','none','InnerPosition',[0 0 480 480]);
  9. co = [65/255, 131/255, 196/255]; % specify the color
  10. % Create animated line object
  11. headMarker = animatedline('LineStyle','none','Marker','o','Color',co,'MarkerFaceColor',co);
  12. body = animatedline('LineStyle','-','LineWidth',1.3,'Color',co); % trajectory
  13. axis([-1,1,-1,1]); axis off; % hide axis

  14. %%
  15. % Parameters
  16. a = 13;
  17. b = 18;
  18. phi = pi * 0;

  19. % Parametric Equation of Lissajous Curve
  20. t = linspace(0,2*pi,1000); % generate 1000 linearly equally spaced points
  21. x = sin(a*t);
  22. y = sin(b*t+ phi);

  23. %%
  24. % Display
  25. for idx = 1:length(t)
  26.     addpoints(headMarker,x(idx),y(idx));
  27.     addpoints(body,x(idx),y(idx));
  28.     drawnow
  29.     % Capture the current plot
  30.     frame = getframe; % snapshot of the current axes
  31.     im{idx} = frame2im(frame); % write image data to `im`
  32.     % Remove previous head marker except for the last one
  33.     if idx~=length(t)
  34.         clearpoints(headMarker);
  35.     end
  36. end


  37. % figure;
  38. % for idx = 1:9
  39. %     subplot(3,3,idx)
  40. %     imshow(im{idx});
  41. % end

  42. %%
  43. % Save images into a GIF file.
  44. % Because three-dimensional data is not supported for GIF files,
  45. % call rgb2ind to convert the RGB data in the image to an indexed image A with a colormap map.
  46. filename = 'Lissajous.gif'; % specify the output file name
  47. for idx = 1:length(t)
  48.     [A,map] = rgb2ind(im{idx},256);
  49.     if idx == 1
  50.         % Set DelayTime = 0 to display next images as fast as your hardware allows
  51.         imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0);
  52.     else
  53.         % To append multiple images to the first image
  54.         imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0);
  55.     end
  56. end


 楼主| gaoyang9992006 发表于 2019-2-9 10:19 | 显示全部楼层
 楼主| gaoyang9992006 发表于 2019-2-9 10:20 | 显示全部楼层
本帖最后由 gaoyang9992006 于 2019-2-9 10:22 编辑

4066522-3f41aa9bc6d2e54f.gif 这是动画效果,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,。。
 楼主| gaoyang9992006 发表于 2019-2-9 10:20 | 显示全部楼层
 楼主| gaoyang9992006 发表于 2019-2-9 10:22 | 显示全部楼层
Lissajous曲线
在数学上,Lissajous曲线(又称Lissajous图形或Bowditch曲线)是由如下参数方程构成的曲线族的图形 [1]
![参数方程][Equation]
[Equation]: http://latex.codecogs.com/svg.latex?\begin{cases}x=A\sin(at+\varphi)\y=B\sin(bt)\end{cases}
纳撒尼尔·鲍迪奇(Nathaniel Bowditch)在1815年首先研究了这一曲线族,之后在1857年由朱尔斯·安东尼·利萨如(Jules Antoine Lissajous)进行了更详细的研究。
在物理上,Lissajous曲线可以看作是一个质点同时在X轴和Y轴方向上做简谐运动形成的运动轨迹(以我仅剩的一点物理知识来说,这大概是叫"运动的合成")。
当这两个相互垂直方向上的简谐振动的频率为任意值时,那么它们合成的运动可能会比较复杂,轨迹是不稳定的,示意图如下。(关于稳定,我的理解大概就是呈周期性吧)
 楼主| gaoyang9992006 发表于 2019-2-9 10:23 | 显示全部楼层
论坛不支持在线的公式解析这太让人头痛了,希望技术给解决了。安装一下这个解析插件。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:如果你觉得我的分享或者答复还可以,请给我点赞,谢谢。

2052

主题

16403

帖子

222

粉丝
快速回复 在线客服 返回列表 返回顶部