i want an animation of a point to follow my curve ??? i have tried but not getting it?

2 次查看(过去 30 天)
clc
clear
% close all
%% Input
CP = 4;
syms u v
Po = [-40 -40 0]; %Attacking missile origin
P1 = [-30 -30 45];
P2 = [-20 -20 35];
P3 = [-10 -10 0]; %Target point
%% Attacking missile(Short range rocket and artillery shells) path using Bazier curve
P= [Po
P1
P2
P3];
U = [u^3 u^2 u 1];
M = [-1 3 -3 1
3 -6 3 0
-3 3 0 0
1 0 0 0];
R(u) = U*M*P ;
%% Indexing of points to draw curve
i=1;
e=100;
for u = 0:1/e:1
C= R(u)
for k = 0:length(i)
Xr(k)= C(i,1);
Yr(k)= C(i,2);
Zr(k)= C(i,3);
% p= C(u,1)
% q= C(u,2)
% r= C(u,3)
rod = plot3(Xr(k),Yr(k),Zr(k),'-o','Color','b','MarkerSize',10,'MarkerFaceColor','#D9FFFF') ;
drawnow
% pause(0.01);
% delete(rod);
end
Xr(i)= C(:,1)
Yr(i)= C(:,2);
Zr(i)= C(:,3);
% for a= 1:e
% Xr(i)= C(a,1)
% Yr(i)= C(a,2)
% Zr(i)= C(a,3)
% end
i=i+1;
end
%% Ploting 3d bazier curve
plot3(P(:,1),P(:,2),P(:,3),'--g*') %ploting control polygon
hold on
p=plot3(Xr,Yr,Zr,'-','Color','r') ; %ploting BAZIER CURVE
p.LineWidth = 2;

回答(1 个)

Image Analyst
Image Analyst 2021-12-3
Try removing the % symbol in front of the pause() and delete() lines.
  3 个评论
Image Analyst
Image Analyst 2021-12-3
Sorry, I don't have the Symbolic Toolbox. Can you convert the u and v to numerical vectors? Then increase the pause to 0.5 seconds.
Rahul Jangid
Rahul Jangid 2021-12-6
bro actually i am new so i dont know how to do it, and
i want to play two loop simultaniously can you suggest me how to do it ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by