next up previous adam-math, MATmatcc, MMKOMP MMkomp2 Adam WILEY-VCH MATLAB-Filme Projekte und M-Files Stefan Adam privat Mail to stefan.r.a.adam@gmail.com MMkomp ed1 Adam
Nächste Seite: Das L vollführt einen Aufwärts: MMkomp2 Filmserie Vorherige Seite: 3D Lissajous-Figuren

Parkhausrampe

Eine hübsche Anwendung, sowohl der Schraubenlinie als auch der homogenen Koordinaten-Transformation zeigt ein vereinfachtes Auto, das eine Parkhausrampe hinauffährt.

 function voidbk = parkhausfilm(varargin);
% parkhausfilm.m simple Simulation der Bewegung
% eines vereinfachten Autos auf einer  Parkhausrampe
figure(1); clf;
voidbk = 0;
 winpr = 40*pi/180; tetpr = -15*pi/180; 
 wfmxl =    [0  0.3 0.3 0.5  0.9 1.1  1.1 3.5 3.5 3.7 4.1 4.3 4.3 4.7];
 wfmzl  = [ 0.3 0.3 0.3  0   0   0.3  0.3  0.3 0.3 0   0  0.3  0.3  0.3  ];
 wfmyl = 0.75*ones(1,14) ;  wfmyl(3:6) = 0.68; wfmyl(9:12) = 0.68;
 wdxl =  [0.1 1.7 3.4  4.4  4.7 4.4  3.4];
 wdzl =  [0.6 1.7 1.7  1.2  0.3 1.2  1.7];
 wfxl = [0.1 0.9  2.2  2.4];
 wfzl = [0.6 1.15  1.25 1.7];
 wfmx = [wfmxl fliplr(wfmxl) 0 wdxl fliplr(wdxl) 0 ...
         wfxl  fliplr(wfxl) 0.1 0.1  0.9 0.9  1.7  1.7]  - 3.5;
 wfmy = [wfmyl -fliplr(wfmyl) 0.75 0.75*ones(1,7) -0.75*ones(1,7) -0.75 ...
    -0.75*ones(1,4) 0.75*ones(1,4) 0.75 -0.75 -0.75 0.75 0.75 -0.75] + 6;
 wfmz = [wfmzl fliplr(wfmzl) 0.3  wdzl fliplr(wdzl) 0.3 ...
         wfzl  fliplr(wfzl) 0.6 0.6  1.15  1.15 1.7 1.7]  ;
 %
 carsim = [wfmy ; -wfmx ; wfmz ; ones(1,58)] ;
 URO = [1 0 0 0 ; 0 cos(0.1) -sin(0.1)  0;  ...
                0  sin(0.1) cos(0.1)  0 ; 0 0 0 1  ];
%
 carpos = URO*carsim;
 t = (0:0.005:1)*2*pi;
xi = 4.0*cos(t);
yi = 4.0*sin(t);
xa = 8.8*cos(t);
ya = 8.8*sin(t);
z = t/2/pi*4.4;
winpr = 74/180*pi;  tetpr = -19/180*pi;
%  innerer Rand der Helix
hdi = plot3ers(xi,yi,z, winpr, tetpr, 0,-5, 'b', 2) ;
axis([-10 10 -10 10]); axis square;
hold on
axis off
hdtx = text(-8,6,'Parkhaus-Rampe', ...
    'FontUnits','points','FontSize',18 , ...
   'Fontweight','demi');
% Aeusserer Rand der Helix
  hdo = plot3ers(xa,ya,z, winpr, tetpr, 0,-5, 'b', 2);
%
for k=1:201
  tx = t(k);
  T = [cos(tx) -sin(tx) 0  0; sin(tx) cos(tx) 0 0; 0 0 1 z(k); 0 0 0 1];
  Q=T*carpos;
  phn = plot3ers(Q(1,:),Q(2,:),Q(3,:), winpr, tetpr, 0,-5, 'r', 2);
  if k > 1
    delete(pho)
  end
    pho = phn;
    if k ==5
    %  pause
    end
  pause(0.04)
end
pause(0.8)
delete(hdi); delete(hdo); delete( pho)
  delete(hdtx)
function plhdb = plot3ers(x,y,z,w,t,xof,yof,col,thik)
% function plhdb = plot3ers(x,y,z,w,t,xof,yof,col,thik)
% Ersatz fuer plot3
%  mit Zusatz-Parametern   w , t horizontaler und vertikaler Drehwinkel
%  xof, yof  x- und y- Offset (Zusatz) nach Projektion in 2D
%  col  Farbe und thik Liniendicke
%  Rueckgabe plhdb  plot-handle des 2D plot-Aufrufs
zrm = [cos(w) -sin(w) 0;  sin(w) cos(w) 0 ; 0 0 1];
yrm = [  cos(t) 0 -sin(t) ; 0 1 0;  sin(t) 0  cos(t) ];
trko = yrm*zrm*[x;y;z];
plhdb = plot(trko(2,:)+xof, trko(3,:)+yof,col,'LineWidth',thik); 
end
  end



2018-09-15