190 likes | 385 Views
Unit 6 Animation Design. 中華技術學院電子系 蔡樸生 副教授 林盈灝 副教授. MOVIES. Animation in MATLAB takes one of two forms (1) Movies Feature : The computations needs to create a sequence of images Real – time rendering is fatal drawback The approach require significant memory space
E N D
Unit 6 Animation Design 中華技術學院電子系 蔡樸生 副教授 林盈灝 副教授
MOVIES • Animation in MATLAB takes one of two forms (1) Movies Feature : • The computations needs to create a sequence of images • Real – time rendering is fatal drawback • The approach require significant memory space (2) Movies procedure • moviein : 預留記憶體空間 • getframe:抓取圖形作為電影畫面 • movie :播放電影(重複次數與每秒播放畫面數目)
Example : rotate a 3-D surface plot • n=10; • peaks; translating and scaling Gaussian distributions • M=moviein(n) • for j=1:n • view(-37.5+j*10,30);view(Azimuth,Elevation) • M(j)=getframe; • end • movie(M,20); MOVIE(M,N,FPS) • default if FPS is omitted is 12 frames per second.
Handle Graphics Demo • lorenz : Chaotic Equation • truss : Earthquake Simulation • travel : Traveling Salesperson Problem • firdemo : Downhill Simplex Search • spinner : Screen Protection • sltbu : Auto Parking • juggle : Fuzzy Controller • slbb / slcp1 / slcpp1 / invkine
Handle Graphics Animation • curve properties • x data : vector • y data : vector • EraseMode : 曲線被抹除的模式 • normal : 重畫整個畫面 • xor : 將舊曲線的點以xor方式還原 • background :將舊曲線的點改成背景顏色 • none : 保留舊曲線的點,不做任何處理 • 動畫原理 : 產生一條曲線 , 設定 EraseMode 更新 x data 與 y data
Example : exponent-sinewave function • x=0:0.1:8*pi; • h=plot(x,sin(x).*exp(-x/5),'EraseMode','xor'); • for i=1:100 • y=sin(x+i/10).*exp(-x/5); • set(h,'ydata',y); • drawnow ; 令Matlab 立即處理 set 動作 • end
Mobile Robots Animation Principle bcar2 bcar1 bcar3 bcar4
Example : Mobile Robots Configuration (1) The Body of Mobile Robot function [h6,h7,h8]=create4_robot(xc,yc,sita) car_length=0.8; car_width=0.5;(1/2 車身與車寬) whl_head=0.6;whl_back=0.3;whl_width=0.3; center=[xc yc]'; bcar_1=[car_length car_width]'; bcar_2=[-car_length car_width]'; bcar_3=[-car_length -car_width]'; bcar_4=[car_length -car_width]'; rotation=[cos(sita) -sin(sita);sin(sita) cos(sita)];
The Body Of Mobile Robot icar_1=rotation*bcar_1+center; icar_2=rotation*bcar_2+center; icar_3=rotation*bcar_3+center; icar_4=rotation*bcar_4+center; pcarx=[icar_1(1,1) icar_2(1,1) icar_3(1,1) icar_4(1,1) icar_1(1,1)]; pcary=[icar_1(2,1) icar_2(2,1) icar_3(2,1) icar_4(2,1) icar_1(2,1)]; h6=line(pcarx,pcary); set(h6,'color',[1 0 1]);
The Wheels Of Mobile Robot bwhl_1=[whl_head whl_width]'; bwhl_2=[whl_back whl_width]'; bwhl_3=[whl_back -whl_width]'; bwhl_4=[whl_head -whl_width]'; iwhl_1=rotation*bwhl_1+center; iwhl_2=rotation*bwhl_2+center; iwhl_3=rotation*bwhl_3+center; iwhl_4=rotation*bwhl_4+center; pwhlx=[iwhl_1(1,1) iwhl_2(1,1)]; pwhly=[iwhl_1(2,1) iwhl_2(2,1)];
The Wheels Of Mobile Robot h7=line(pwhlx,pwhly); set(h7,'color',[0 0 0]); pwhlx=[iwhl_3(1,1) iwhl_4(1,1)]; pwhly=[iwhl_3(2,1) iwhl_4(2,1)]; h8=line(pwhlx,pwhly); set(h8,'color',[0 0 0]); h9=line(xc,yc); set(h9,'color',[1 0 0]); set(h9,'Marker','.');
Home works (1) Design the configuration of tank (2) Adding a friendly windows for simulation
Example1 : 3D Rotate about X , Y , Z P6-P7-P5-P4-P6-P0-P1-P2-P3-P0-P6-P4-P3-P2-P5-P7-P1
The Rotation Matrix Representation (I) ROTATE ABOUT X AXIS
The Rotation Matrix Representation (II) ROTATE ABOUT Y AXIS
The Rotation Matrix Representation (III) ROTATE ABOUT Z AXIS
Example 3: The kinematic model of a mobile robot M=I=L=R=1 Initial Value :