how can i move an object (eg a rectangle) on a function path(eg. a pulse or sigmoid function) one important thing to note that {the object should not change its face while turning eg like a car moves.} please help sooner as possible
Show older comments
i have tried it like this. first make a matrix of centroid of the rectangle and a matrix of the coordinates of x and y axis of the function. then add every single coordinate the the centroid but the rectangle is still not moving. one very important thing to note is that the face of the object should not change while turning i.e it should not move laterally the same movement as the car does. i need the code. please help. as soon as possible. thank you
Answers (1)
KSSV
on 25 Jun 2016
clc; clear all ;
x = [-1 1 1 -1 -1]/4 ;
y = [-1 -1 1 1 -1]/4 ;
%
t = linspace(0,2*pi) ;
yp = sin(pi*t) ;
for i = 1:length(t) ;
xi = x+t(i) ;
yi = y+yp(i) ;
plot(t,yp,'r') ;
hold on
patch(xi,yi,'b') ;
hold off
pause(0.1)
end
4 Comments
sonam pankaj
on 25 Jun 2016
KSSV
on 25 Jun 2016
it is always in same direction....
sonam pankaj
on 25 Jun 2016
sonam pankaj
on 25 Jun 2016
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!