Moving a Polygon on a Polygon

6 views (last 30 days)
Francesco Curth
Francesco Curth on 14 Aug 2019
Commented: Francesco Curth on 14 Aug 2019
Hello,
I created following Polygons on top of each other:
pgon = polyshape([440 0 0 440], [0 0 5.1 5.1]);
pgon2 = polyshape([18 0 0 18], [0 0 0.5 0.5]);
plot([pgon pgon2]);
Now I want that the smaller polygon moves from on side to the other and over and over again and moves up a little each time.
Is this possible. And if yes how?

Accepted Answer

KSSV
KSSV on 14 Aug 2019
pgon = polyshape([440 0 0 440], [0 0 5.1 5.1]);
path = [1:5:100 100:-5:1] ;
for i = path
pgon2 = polyshape([18 0 0 18]+i, [0 0 0.5 0.5]);
plot([pgon pgon2]);
drawnow
end

More Answers (0)

Categories

Find more on Elementary Polygons 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!