I am trying to do an animation, with a rectangle, which should change dimension every time it touch the wall (taller and thinner). I did something like that, and it is not so bad, but area should be always the same and now it is not. Other bad thing is that it is not touching right wall. And it should be always on this same height but it's not. Can You please help me with these problems?
My code:
clear all;clc;x=[0 0 100 100 0];y=[0 100 100 0 0];plot(x,y,'black');axis([-10 110 -10 110]);hold on;g = hgtransform;x=[50 50 100 100 50];y=[37.5 62.5 62.5 37.5 37.5];patch('XData',x,'YData',y,'FaceColor','white','Parent',g)pt1 = [-50 0 0];pt2 =[1 1 1]for i=1:1:1000for t=linspace(0,1,250) b = makehgtform('scale',pt2,'translate',t*(pt1)); set(g,'Matrix',b) drawnowendpt2=pt2+[-0.125 0.125 0];for t=linspace(1,0,250) b = makehgtform('scale',pt2,'translate',t*(pt1)); set(g,'Matrix',b) drawnowendpt2=pt2+[-0.125 0.125 0];end
Best Answer