打印

Lissajous曲线动画演示

[复制链接]
814|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
%% Animation demo for Lissajous curve
close all;clear;clc;

%%
% 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);
y = sin(b*t+ phi);

%%
% 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


% figure;
% for idx = 1:9
%     subplot(3,3,idx)
%     imshow(im{idx});
% end

%%
% 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


相关帖子

沙发
gaoyang9992006|  楼主 | 2019-2-9 10:19 | 只看该作者

使用特权

评论回复
板凳
gaoyang9992006|  楼主 | 2019-2-9 10:20 | 只看该作者
本帖最后由 gaoyang9992006 于 2019-2-9 10:22 编辑

这是动画效果,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,。。

使用特权

评论回复
地板
gaoyang9992006|  楼主 | 2019-2-9 10:20 | 只看该作者

使用特权

评论回复
5
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轴方向上做简谐运动形成的运动轨迹(以我仅剩的一点物理知识来说,这大概是叫"运动的合成")。
当这两个相互垂直方向上的简谐振动的频率为任意值时,那么它们合成的运动可能会比较复杂,轨迹是不稳定的,示意图如下。(关于稳定,我的理解大概就是呈周期性吧)

使用特权

评论回复
6
gaoyang9992006|  楼主 | 2019-2-9 10:23 | 只看该作者
论坛不支持在线的公式解析这太让人头痛了,希望技术给解决了。安装一下这个解析插件。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

认证:西安公路研究院南京院
简介:主要工作从事监控网络与通信网络设计,以及从事基于嵌入式的通信与控制设备研发。擅长单片机嵌入式系统物联网设备开发,音频功放电路开发。

1898

主题

15644

帖子

199

粉丝