Lissajous曲线动画演示(Matlab实现)
2017-07-03 01:41
495 查看
在别人的博文里看到 Lissajous曲线的动态图, 感觉还挺帅,于是自己也想玩一下。
最终效果
{x=Asin(at+φ)y=Bsin(bt)
纳撒尼尔·鲍迪奇(Nathaniel Bowditch)在1815年首先研究了这一曲线族,之后在1857年由朱尔斯·安东尼·利萨如(Jules Antoine Lissajous)进行了更详细的研究。
在物理上,Lissajous曲线可以看作是一个质点同时在X轴和Y轴方向上做简谐运动形成的运动轨迹(以我仅剩的一点物理知识来说,这大概是叫”运动的合成”)。
当这两个相互垂直方向上的简谐振动的频率为任意值时,那么它们合成的运动可能会比较复杂,轨迹是不稳定的,示意图如下。(所谓稳定,我的理解大概就是呈周期性吧)
一个示意图
而如果这两个振动的频率成简单的整数比,就能合成一个规则的、稳定的闭合曲线,这就是Lissajous曲线(示意图如下)。
另一个示意图
完整代码链接
https://codepen.io/handsomeone/full/Kgmbqg
https://cn.mathworks.com/matlabcentral/fileexchange/28987-lissajous-curve
https://cn.mathworks.com/examples/matlab/community/22655-lissajous-curves
http://www.baike.com/wiki/%E5%88%A9%E8%90%A8%E5%A6%82%E5%9B%BE%E5%BD%A2
本文作者: 小路
本文链接: http://tinyland.site/posts/2017-07-02-matlab-implementation-for-lissajous-curve-animation-demo.html
最终效果
Lissajous曲线
在数学上,Lissajous曲线 [1] (又称Lissajous图形或Bowditch曲线)是由如下参数方程构成的曲线族的图形{x=Asin(at+φ)y=Bsin(bt)
纳撒尼尔·鲍迪奇(Nathaniel Bowditch)在1815年首先研究了这一曲线族,之后在1857年由朱尔斯·安东尼·利萨如(Jules Antoine Lissajous)进行了更详细的研究。
在物理上,Lissajous曲线可以看作是一个质点同时在X轴和Y轴方向上做简谐运动形成的运动轨迹(以我仅剩的一点物理知识来说,这大概是叫”运动的合成”)。
当这两个相互垂直方向上的简谐振动的频率为任意值时,那么它们合成的运动可能会比较复杂,轨迹是不稳定的,示意图如下。(所谓稳定,我的理解大概就是呈周期性吧)
一个示意图
而如果这两个振动的频率成简单的整数比,就能合成一个规则的、稳定的闭合曲线,这就是Lissajous曲线(示意图如下)。
另一个示意图
具体实现
环境: Matlab R2017aAnimated Line 实现动画效果
首先用animatedline创建初始动画线条对象 [2] ,接着在循环中动态地向线条中添加点,并使用
drawnow在屏幕上显示该新添加的点,然后用
getframe捕获的当前图像。
%% % Create a new figure window, % Background color is white % MenuBar is hidden % Image size is 480*480 figure('Color','w','MenuBar','none','InnerPosition',[0 0 480 480]); co = [65/255, 131/255, 196/255]; % specify the color % Create animated line object headMarker = animatedline('LineStyle','none','Marker','o','Color',co,'MarkerFaceColor',co); body = animatedline('LineStyle','-','LineWidth',1.3,'Color',co); % trajectory axis([-1,1,-1,1]); axis off; % hide axis %% % Parameters a = 13; b = 18; phi = pi * 0; % Parametric Equation of Lissajous Curve t = linspace(0,2*pi,1000); % generate 1000 linearly equally spaced points x = sin(a*t + phi); y = sin(b*t); %% % Display for idx = 1:length(t) addpoints(headMarker,x(idx),y(idx)); addpoints(body,x(idx),y(idx)); drawnow % Capture the current plot frame = getframe; % snapshot of the current axes im{idx} = frame2im(frame); % write image data to `im` % Remove previous head marker except for the last one if idx~=length(t) clearpoints(headMarker); end end
写入GIF动图
将getframe捕获的每一个图像,写入 GIF 动画文件 [3] 。
%% % Save images into a GIF file. % Because three-dimensional data is not supported for GIF files, % call rgb2ind to convert the RGB data in the image to an indexed image A with a colormap map. filename = 'Lissajous.gif'; % specify the output file name for idx = 1:length(t) [A,map] = rgb2ind(im{idx},256); if idx == 1 % Set DelayTime = 0 to display next images as fast as your hardware allows imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0); else % To append multiple images to the first image imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0); end end
完整代码链接
参考
http://www.matrix67.com/blog/archives/6947https://codepen.io/handsomeone/full/Kgmbqg
https://cn.mathworks.com/matlabcentral/fileexchange/28987-lissajous-curve
https://cn.mathworks.com/examples/matlab/community/22655-lissajous-curves
http://www.baike.com/wiki/%E5%88%A9%E8%90%A8%E5%A6%82%E5%9B%BE%E5%BD%A2
本文作者: 小路
本文链接: http://tinyland.site/posts/2017-07-02-matlab-implementation-for-lissajous-curve-animation-demo.html
相关文章推荐
- MATLAB实现坐标系变换动画演示
- MATLAB实现寻路、布线、迷宫的递归深度优先遍历算法_动画演示
- javafx实现利萨茹(Lissajous)曲线动画
- Matlab实现Galton板的动画演示
- MATLAB实现直接插入排序的演示动画
- listview中listitem点击实现沿曲线移动动画效果
- 多线程实现凸壳算法的动画演示(2)类设计
- 限制CheckBoxList控件只能单选实现代码及演示动画
- 使用JavaScript动态设置样式实现代码及演示动画
- 用MATLAB怎么实现曲线拟合?
- jQuery实现的点赞随机数字显示动画效果(附在线演示与demo源码下载)
- MATLAB图像处理与计算机视觉(3):实现Carsten Steger 的曲线检测算法(1)
- 帧动画的完整实现: 代码直接演示
- 小波图像融合的Matlab实现示例(添加图片演示080428)
- MATLAB中利用cftool导出代码实现一张图中拟合多条平滑曲线
- jQuery实现的给图片点赞+1动画效果(附在线演示及demo源码下载)
- 人口预测模型Matlab实现Logistic曲线模型
- 读取XML并绑定至RadioButtonList实现思路及演示动画
- 最小二乘曲线拟合matlab实现
- 多线程实现凸壳算法的动画演示(1)需求分析