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

조회 수: 1 (최근 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