how to reduce this circle
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I made this matlabfile: I only don't understand why the rotating blue ''circle'' is bigger then the circle before rotating? can please anyone help me
if true
% code
t = linspace(0,2*pi,1000)
h1=3; %y-coordinaat center van circel 1
k1=3; %z-coordinaat center van circel 1
r1=0.2; %straal cirkel 1
h2=5;%y-coordinaat center van circel 2
k2=3; %y-coordinaat center van circel 2
r2=0.1 %straal cirkel 2
%cirkel 1
y1 = r1*cos(t)+h1;
z1 = r1*sin(t)+k1;
%cirkel 2
y2 = r2*cos(t)+h2;
z2 = r2*sin(t)+k2;
% grafiek 1
S1 = subplot(1,2,1);
ha=fill(y1,z1,'r'); %cirkel 1
hold on
hb=fill(y2,z2,'b'); %cirkel 2
hold on
hc=plot([h1,h2],[k1,k2],'k') %lijn tussen de cirkels
L = fill(y2,z2,'b'); % cirkel 2 die om de as van cirkel 1 gaat draaien
title('Before Rotation')
axis([0 6 0 6]);
axis('square');
P = [0,0,1]; % Rotatie vector
Rp = [h1 k1]; % Het punt waarom gedraaid gaat worden
%grafiek 2
S2 = subplot(1,2,2);
L = fill(y2,z2,'b')
Xd = get(L,'xdata');
Yd = get(L,'ydata');
K2 = plot(Xd,Yd,'*');
title('After Rotation')
axis([0 6 0 6]);
axis('square');
hold on
ha=fill(y1,z1,'r'); %cirkel 1
hold on
hb=fill(y2,z2,'b'); %cirkel 2
hold on
hc=plot([h1,h2],[k1,k2],'k'); %lijn tussen de twee cirkels
hold on
plot(Rp(1),Rp(2),'*r')
L2 = plot([h1,h2],[k1,k2],'k');
XL = get(S1,'xlim');
YL = get(S1,'ylim');
Dx = diff(XL);
Dy = diff(YL);
for ii = 1:72
set(S2,'xlim',[Rp(1)-Dx Rp(1)+Dx],'ylim',[Rp(2)-Dy Rp(2)+Dy])
rotate(K2,P,5) % draait 5 graden per tijd
set(S2,'xlim',[Rp(1)-Dx Rp(1)+Dx],'ylim',[Rp(2)-Dy Rp(2)+Dy])
rotate(L2,P,5) % draait 5 graden per tijd
xlim(XL)
ylim(YL)
pause(.05)
end
end
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactions, Camera Views, and Lighting finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!