|
楼主 |
发表于 2008-5-5 13:40
|
显示全部楼层
定义:当半径为b的圆沿着半径为a的定圆的外侧无滑动地滚动时,动圆圆周上的一点p所描绘的点的轨迹。
在以定圆中心为原点的直角坐标系中,其方程为
x=(a+b)cosθ-bcos[(a+b)θ/b];
y=(a+b)sinθ-bsin[(a+b)θ/b];
function epicycloid(ra,rb)
fig=figure;
set(fig,'Color',[1,1,1]);
theta=0:pi/50:2*pi;
xa=ra*cos(theta); % 定圆x坐标
ya=ra*sin(theta); % 定圆y坐标
xb=rb*cos(theta-pi); % 动圆x坐标
yb=rb*sin(theta-pi); % 动圆y坐标
xc=(ra+rb)*cos(theta)-rb*cos((ra+rb)*theta/rb); % 摆线x坐标
yc=(ra+rb)*sin(theta)-rb*sin((ra+rb)*theta/rb); % 摆线y坐标
xax=[-1.2*ra,1.2*ra];
yax=[-1.2*ra,1.2*ra];
m=length(theta);
mov=avifile('epicycloid.avi');
for i=1:m
plot(xax,[0,0],'k',[0 0],yax,'k');
hold on
plot(xa,ya,'k','linewidth',2);
plot(xc(1,[1:i]),yc(1,[1:i]),'r','linewidth',2);
AA=[cos((ra+rb)*theta(i)/rb) -sin((ra+rb)*theta(i)/rb);sin((ra+rb)*theta(i)/rb) cos((ra+rb)*theta(i)/rb)]*[xb;yb];
xbb=AA(1,:);
ybb=AA(2,:);
xbb=xbb+(ra+rb)*cos(theta(i));
ybb=ybb+(ra+rb)*sin(theta(i));
plot(xbb,ybb,'b','linewidth',2);
plot(xbb(1),ybb(1),'o','linewidth',2,'markeredgecolor','k','markerfacecolor','g');
plot([xbb(1) xbb((m-1)/2)],[ybb(1) ybb((m-1)/2)],'k',[xbb((m-1)/4) xbb(3*(m-1)/4)],[ybb((m-1)/4) ybb(3*(m-1)/4)],'k')
axis([-1.2*(ra+rb),1.2*(ra+rb),-1.2*(ra+rb),1.2*(ra+rb)]);
axis equal
axis off
F=getframe(gcf);
mov=addframe(mov,F);
hold off
end
mov = close(mov);
[ 本帖最后由 paradiseboy 于 2008-5-5 13:50 编辑 ] |
-
|