Creating Curve from Moving Point
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Allison Bushman
am 5 Mär. 2019
Kommentiert: Allison Bushman
am 5 Mär. 2019
I want to create curves based on moving points P6 and P7. Here is what I have so far. Can someone please tell me how I can create a curve that could be used to calculate the area between two points?
hold on
axis ([-20 20 -20 20])
axis off
P1=[-11,0];
P2=[-1,0];
h{1}=plot([P1(1) P2(1)],[P1(2) P2(2)],'LineWidth',5,'Color','black');
x=5*pi/8;
b=0:pi/40:x;
P6vct=nan(numel(b),2)
P7vct=nan(numel(b),2);
for k=1:numel(b)
Z=[4,0];
h{2}=viscircles(Z,5,'LineWidth',2,'LineStyle','--','Color','black');
A=[0,0];
h{3} = viscircles(A,1,'LineWidth',2,'Color','black');
PA=A+[cos(b(k)-(pi)),sin(b(k)-(pi))];
h{4}=viscircles(PA,.1,'Color','black');
B = [4-4*cos(2*asin(.25)),-4*sin(2*asin(.25))];
h{5} = viscircles(B,1,'LineWidth',2,'Color','green');
PB=B+[cos(-b(k)-(pi/2)),sin(-b(k)-(pi/2))];
h{6}=viscircles(PB,.1,'Color','green');
C = [4-4*cos(4*asin(.25)),-4*sin(4*asin(.25))];
h{7} = viscircles(C,1,'LineWidth',2,'Color','blue');
PC=C+[cos(b(k)-(pi/2)),sin(b(k)-(pi/2))];
h{8}=viscircles(PC,.1,'Color','blue');
D = [4-4*cos(6*asin(.25)),-4*sin(6*asin(.25))];
h{9} = viscircles(D,1,'LineWidth',2,'Color','red');
PD=D+[cos(-b(k)-(pi/2)),sin(-b(k)-(pi/2))];
h{10}=viscircles(PD,.1,'Color','red');
E = [4-4*cos(8*asin(.25)),-4*sin(8*asin(.25))];
h{11} = viscircles(E,1,'LineWidth',2,'Color','yellow');
PE=E+[cos(b(k)-(pi/2)),sin(b(k)-(pi/2))];
h{12}=viscircles(PE,.1,'Color','yellow');
P3=B+[cos(b(k)),sin(b(k))];
P4=C+[cos(b(k)),sin(b(k))];
P5=D+[cos(b(k)),sin(b(k))];
P6=E+[cos(b(k)-x),sin(b(k)-x)];
P7=E+[11*cos(b(k)-x),11*sin(b(k)-x)];
P6vct(k,:)=P6;
P7vct(k,:)=P7;
h{13} = plot([P6(1) P7(1)],[P6(2) P7(2)],'LineWidth',5,'Color','black');
%h{14}=plot(P6vct(:,1),P6vct(:,2),'LineWidth',3,'Color','black');
curve1=[P6vct(:,1),P6vct(:,2)];
curve2=[P7vct(:,1),P7vct(:,2)];
%h{15}=plot(curve2,'LineWidth',3,'Color','black');
drawnow();
pause(0.001);
if k<numel(b)
delete(vertcat(h{2:13}));
end
area(curve1)
fill(curve1,curve2,'blue');
str = {'Area Swept:'};
annotation('textbox',[0.2 0.5 0.3 0.3],'String',str,'FitBoxToText','on');
end
hold off
axis ([-20 20 -20 20])
axis off
2 Kommentare
Akzeptierte Antwort
KSSV
am 5 Mär. 2019
hold on
axis ([-20 20 -20 20])
axis off
P1=[-11,0];
P2=[-1,0];
h{1}=plot([P1(1) P2(1)],[P1(2) P2(2)],'LineWidth',5,'Color','black');
x=5*pi/8;
b=0:pi/40:x;
P6vct=nan(numel(b),2)
P7vct=nan(numel(b),2);
cP6 = zeros([],2) ;
cP7 = zeros([],2) ;
for k=1:numel(b)
Z=[4,0];
h{2}=viscircles(Z,5,'LineWidth',2,'LineStyle','--','Color','black');
A=[0,0];
h{3} = viscircles(A,1,'LineWidth',2,'Color','black');
PA=A+[cos(b(k)-(pi)),sin(b(k)-(pi))];
h{4}=viscircles(PA,.1,'Color','black');
B = [4-4*cos(2*asin(.25)),-4*sin(2*asin(.25))];
h{5} = viscircles(B,1,'LineWidth',2,'Color','green');
PB=B+[cos(-b(k)-(pi/2)),sin(-b(k)-(pi/2))];
h{6}=viscircles(PB,.1,'Color','green');
C = [4-4*cos(4*asin(.25)),-4*sin(4*asin(.25))];
h{7} = viscircles(C,1,'LineWidth',2,'Color','blue');
PC=C+[cos(b(k)-(pi/2)),sin(b(k)-(pi/2))];
h{8}=viscircles(PC,.1,'Color','blue');
D = [4-4*cos(6*asin(.25)),-4*sin(6*asin(.25))];
h{9} = viscircles(D,1,'LineWidth',2,'Color','red');
PD=D+[cos(-b(k)-(pi/2)),sin(-b(k)-(pi/2))];
h{10}=viscircles(PD,.1,'Color','red');
E = [4-4*cos(8*asin(.25)),-4*sin(8*asin(.25))];
h{11} = viscircles(E,1,'LineWidth',2,'Color','yellow');
PE=E+[cos(b(k)-(pi/2)),sin(b(k)-(pi/2))];
h{12}=viscircles(PE,.1,'Color','yellow');
P3=B+[cos(b(k)),sin(b(k))];
P4=C+[cos(b(k)),sin(b(k))];
P5=D+[cos(b(k)),sin(b(k))];
P6=E+[cos(b(k)-x),sin(b(k)-x)];
P7=E+[11*cos(b(k)-x),11*sin(b(k)-x)];
P6vct(k,:)=P6;
P7vct(k,:)=P7;
cP6(k,:) = P6 ;
cP7(k,:) = P7 ;
h{13} = plot([P6(1) P7(1)],[P6(2) P7(2)],'LineWidth',5,'Color','black');
%h{14}=plot(P6vct(:,1),P6vct(:,2),'LineWidth',3,'Color','black');
curve1=[P6vct(:,1),P6vct(:,2)];
curve2=[P7vct(:,1),P7vct(:,2)];
%h{15}=plot(curve2,'LineWidth',3,'Color','black');
drawnow();
pause(0.001);
if k<numel(b)
delete(vertcat(h{2:13}));
end
area(curve1)
fill(curve1,curve2,'blue');
str = {'Area Swept:'};
annotation('textbox',[0.2 0.5 0.3 0.3],'String',str,'FitBoxToText','on');
end
plot(cP6(:,1),cP6(:,2),'r')
plot(cP7(:,1),cP7(:,2),'b')
hold off
axis ([-20 20 -20 20])
axis off
5 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading 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!