Lissajous曲线动画演示(Matlab实现)
来源:互联网 发布:淘宝客推广海报 编辑:程序博客网 时间:2024/05/21 09:04
在别人的博文里看到 Lissajous曲线的动态图, 感觉还挺帅,于是自己也想玩一下。
Lissajous曲线
在数学上,Lissajous曲线 [1] (又称Lissajous图形或Bowditch曲线)是由如下参数方程构成的曲线族的图形
纳撒尼尔·鲍迪奇(Nathaniel Bowditch)在1815年首先研究了这一曲线族,之后在1857年由朱尔斯·安东尼·利萨如(Jules Antoine Lissajous)进行了更详细的研究。
在物理上,Lissajous曲线可以看作是一个质点同时在X轴和Y轴方向上做简谐运动形成的运动轨迹(以我仅剩的一点物理知识来说,这大概是叫”运动的合成”)。
当这两个相互垂直方向上的简谐振动的频率为任意值时,那么它们合成的运动可能会比较复杂,轨迹是不稳定的,示意图如下。(所谓稳定,我的理解大概就是呈周期性吧)
而如果这两个振动的频率成简单的整数比,就能合成一个规则的、稳定的闭合曲线,这就是Lissajous曲线(示意图如下)。
具体实现
- 环境: Matlab R2017a
Animated Line 实现动画效果
首先用animatedline
创建初始动画线条对象 [2] ,接着在循环中动态地向线条中添加点,并使用 drawnow
在屏幕上显示该新添加的点,然后用getframe
捕获的当前图像。
%%% Create a new figure window,% Background color is white% MenuBar is hidden% Image size is 480*480figure('Color','w','MenuBar','none','InnerPosition',[0 0 480 480]);co = [65/255, 131/255, 196/255]; % specify the color% Create animated line objectheadMarker = animatedline('LineStyle','none','Marker','o','Color',co,'MarkerFaceColor',co);body = animatedline('LineStyle','-','LineWidth',1.3,'Color',co); % trajectoryaxis([-1,1,-1,1]); axis off; % hide axis%% % Parametersa = 13;b = 18;phi = pi * 0;% Parametric Equation of Lissajous Curvet = linspace(0,2*pi,1000); % generate 1000 linearly equally spaced pointsx = sin(a*t + phi);y = sin(b*t);%%% Displayfor 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); endend
写入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 namefor 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); endend
完整代码链接
参考
- http://www.matrix67.com/blog/archives/6947
- 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
阅读全文
0 0
- Lissajous曲线动画演示(Matlab实现)
- Matlab实现Galton板的动画演示
- MATLAB实现坐标系变换动画演示
- MATLAB实现直接插入排序的演示动画
- Unity Mecanim动画的实现(七):动画曲线
- Unity Mecanim动画的实现(七):动画曲线
- precision recall曲线Matlab实现
- 利用贝塞尔曲线实现动画
- MATLAB实现寻路、布线、迷宫的递归深度优先遍历算法_动画演示
- 利用递归算法实现n层汉诺塔动画演示MATLAB代码以及解释
- SVG动画演示贝塞尔曲线(1-4阶)绘制过程
- SVG动画演示贝塞尔曲线(1-4阶)绘制过程
- SVG动画演示贝塞尔曲线(1-4阶)绘制过程
- 查准率-查全率precision recall(PR)曲线Matlab实现
- MEMS振镜扫描的Lissajous图形Matlab仿真
- 演示动画怎么实现的
- 购物车(Activity+Fragment)贝塞尔曲线动画实现
- ROC曲线及其matlab实现ROC曲线的绘画
- 数学建模--二次规划
- 对ElasticSearch的几点思考
- Python的第三方库requests提示警告InsecureRequestWarning的问题
- DPCM
- 递归与分治策略之利用中位数线性时间选择
- Lissajous曲线动画演示(Matlab实现)
- git 基本操作
- 数学中的各种矩阵大总结
- JavaScript高级程序设计-第十章-DOM
- placement new的用法及用途
- JPEG
- Excel图表-用三维柱形图展示各地GDP的对比效果
- 社区发现算法
- 日期相关-1