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;
0 个评论
回答(1 个)
  Image Analyst
      
      
 2021-12-3
        Try removing the % symbol in front of the pause() and delete() lines.
3 个评论
  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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

