本文主要是介绍MATLAB 数理展示:旋转的错觉,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考视频:https://b23.tv/QRQpHi
描述:当小圆半径为大圆一半,且小圆在大圆中做纯滚动运动时,小圆上的各点运动轨迹均为直线,
试验效果:
完整代码:
function PointOnLineInCircle(N)
if nargin<1||N<3N=4;
end
% 0.2157 0.3765 0.5725
% 0.3098 0.5059 0.7412fig=gcf;
fig.Name='PoLiC';
fig.Position=[50 50 600 600];
fig.NumberTitle='off';
fig.MenuBar='none';ax=axes(fig);
ax.Position=[0 0 1 1];
ax.XLim=[-2 2];
ax.YLim=[-2 2];
ax.XColor='none';
ax.YColor='none';
hold(ax,'on');
% grid onthetaB=0;
thetaS=0;pntsTheta=0:2*pi/N:2*pi;for i=1:(length(pntsTheta)-1)plot([cos(pntsTheta(i)),cos(pntsTheta(i)+pi)].*2,...[sin(pntsTheta(i)),sin(pntsTheta(i)+pi)].*2,...'Color',[0.8 0.8 0.8],'LineWidth',1.5)
end
if mod(N,2)==0for i=1:(length(pntsTheta)-1)plot([cos(pntsTheta(i)+2*pi/N/2),cos(pntsTheta(i)+2*pi/N/2+pi)].*2,...[sin(pntsTheta(i)+2*pi/N/2),sin(pntsTheta(i)+2*pi/N/2+pi)].*2,...'Color',[0.8 0.8 0.8],'LineWidth',1.5)end
endtempT=0:0.1:2*pi+0.1;
CPnts=[cos(tempT);sin(tempT)];
plot(CPnts(1,:).*2,CPnts(2,:).*2,'Color',[0.2098 0.4059 0.6412],'LineWidth',2);sCircleHdl=plot(cos(thetaB)+CPnts(1,:),sin(thetaB)+CPnts(2,:),...'Color',[0.3098 0.5059 0.7412],'LineWidth',2);pntsHdl=plot(cos(pntsTheta+thetaS)+cos(thetaB),...sin(pntsTheta+thetaS)+sin(thetaB),...'Color',[0.2157 0.3765 0.5725],'LineWidth',2,'Marker','o',...'MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0],'MarkerSize',6);patchHdl=fill(cos(pntsTheta(1:end-1)+thetaS)+cos(thetaB),...sin(pntsTheta(1:end-1)+thetaS)+sin(thetaB),...[0.8500 0.3250 0.0980],'EdgeColor','none','FaceAlpha',0.1);while 1thetaB=thetaB-2*pi/200;thetaS=thetaS+2*pi/200;sCircleHdl.XData=cos(thetaB)+CPnts(1,:);sCircleHdl.YData=sin(thetaB)+CPnts(2,:);pntsHdl.XData=cos(pntsTheta+thetaS)+cos(thetaB);pntsHdl.YData=sin(pntsTheta+thetaS)+sin(thetaB);patchHdl.XData=cos(pntsTheta(1:end-1)+thetaS)+cos(thetaB);patchHdl.YData=sin(pntsTheta(1:end-1)+thetaS)+sin(thetaB);pause(0.05);
endend
这篇关于MATLAB 数理展示:旋转的错觉的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!