% 4: 4.11.2011 clear; clc; clf %% Graphik in 3D % siehe Kernbichler Skript Sect.15 %% Kurven in 3D % x(t) = t*cos(t); y(t) = t*sin(t); z(t) = t %% via ezpot ezplot3('t*cos(t)','t*sin(t)','t',[0,6*pi]) box on %% via plot3 clc; clf t = linspace(0,6*pi,51); x = t.*cos(t); y = t.*sin(t); z = t; plot3(x,y,z) box on %% Oktaeder (fill3) clear;clc;clf; % Eckpunkte spaltenweise P = [ 1 -1 -1 1 0 0 ; ... 1 1 -1 -1 0 0 ; ... 0 0 0 0 sqrt(2) -sqrt(2) ]; % idx = [1 2 5] ; % Indexvektor: Welche Punkte? fill3( P(1,idx), P(2,idx), P(3,idx), 'y' ); hold on % idx = [2 3 5] ; % Indexvektor: Welche Punkte? fill3( P(1,idx), P(2,idx), P(3,idx), 'y' ); % idx = [3 4 5] ; fill3( P(1,idx), P(2,idx), P(3,idx), 'y' ); % idx = [4 1 5]; fill3( P(1,idx), P(2,idx), P(3,idx), 'y' ); % idx = [1 2 6] ; % Indexvektor: Welche Punkte? fill3( P(1,idx), P(2,idx), P(3,idx), 'm' ); % idx = [2 3 6]; % Indexvektor: Welche Punkte? fill3( P(1,idx), P(2,idx), P(3,idx), 'm' ); % idx = [3 4 6]; fill3( P(1,idx), P(2,idx), P(3,idx), 'm' ); % idx = [4 1 6]; fill3( P(1,idx), P(2,idx), P(3,idx), 'm' ); alpha(0.7); % Mass der Undurchsichtigkeit aus [0,1] axis equal %% Oktaeder (trisurf) clear;clc;clf; % Eckpunkte spaltenweise P = [ 1 -1 -1 1 0 0 ; ... 1 1 -1 -1 0 0 ; ... 0 0 0 0 sqrt(2) -sqrt(2) ]; % Wir benoetigen eine Matrix, welche zeilenweise die jeweils eine % Dreiecksflaeche beschreibenden Punkte auflistet tri = [ 1 2 5; 2 3 5; 3 4 5; 4 1 5; 1 2 6; 2 3 6; 3 4 6; 4 1 6 ]; trisurf(tri,P(1,:), P(2,:), P(3,:)) % und noch eine Schnittebene des Oktaeders hold on idx = [1 5 3 6]; fill3( P(1,idx), P(2,idx), P(3,idx), 'r' ); view(60,60); % Blickwinkel in 3D alpha(0.6); % Mass der Undurchsichtigkeit aus [0,1] axis equal %% Funktionsflaeche im Raum (ezsurf, ezmesh, ezplot) % z(x,y) = sqrt(x^2+y^2) clear;clc;clf; ezsurf('sqrt(x^2+y^2)') axis equal %% Funktionsflaeche im Raum via Meshgrid % z(x,y) = sqrt(x^2+y^2) clear;clc;clf; % 1D-Koordinaten x = linspace(-5,5,21); y = x; % generieren das Rechteckgitter aus den 1D-Koordinaten [XX,YY] = meshgrid(x,y); % Funktionswerte berechnen ZZ = sqrt(XX.^2+YY.^2); % Zeichnen surf(XX,YY,ZZ) axis equal %% Funktionsflaeche im Raum via Meshgrid und Polarkoordinaten % z(r) = r = sqrt(x^2+y^2) clear;clc;clf; % 1D-Polarkoordinaten phi = linspace(0,2*pi,37); r = linspace(0,5,11); % generieren das Rechteckgitter aus den 1D-Koordinaten [PP,RR] = meshgrid(phi,r); % Funktionswerte berechnen ZZ = RR; % in kartesische Koordinaten umwandeln [XX,YY] = pol2cart(PP,RR); % Zeichnen surf(XX,YY,ZZ) axis equal %% Schraubenflaeche % siehe Schraube.m % %% Rotationskoerper: um z-Achse % % Kegel % % h(r) = z(r) = 5/2*r % clear;clc;clf; % % 1D-Polarkoordinaten % phi = linspace(0,2*pi,37); % r = linspace(0,2,11); % % generieren das Rechteckgitter aus den 1D-Koordinaten % [PP,RR] = meshgrid(phi,r); % % Hoehe als Funktion des Radius berechnen % ZZ = 5/2*RR; % % in kartesische Koordinaten umwandeln % [XX,YY] = pol2cart(PP,RR); % % Zeichnen % % |-------Rotationsachse % surf(XX,YY,ZZ) % title('Rotation um z-Achse') % axis equal % % %% Rotationskoerper: um y-Achse % % wie oben, nur Vertauschen Rotationsachse noetig % % % |-------Rotationsachse % surf(XX,ZZ,YY) % title('Rotation um y-Achse') % % %publish('v_4b');