top of page

Η τρισδιάστατη καμπύλη Peano


Σε προηγούμενη ανάρτηση έχουμε μιλήσει για την καμπύλη Peano. Μια καμπύλη που γεμίζει το επίπεδο, όπως λέμε, δηλαδή διέρχεται από όλα τα σημεία του μοναδιαίου τετραγώνου [0,1]^2. Με παρόμοια λογική μπορούμε να κατασκευάσουμε μια τρισδιάστατη καμπύλη που να γεμίζει το χώρο, δηλαδή το μοναδιαίο κύβο [0,1]^3.


Για να το πετύχουμε αυτό, χωρίζουμε τον μοναδιαίο κύβο σε 27 μικρότερους κύβους και απεικονίζουμε την αρχική τρισδιάστατη πολυγωνική γραμμή (σε σμίκρυνση κατά το 1/3) σε κάθε ένα μικρότερο κύβο. Αν συνεχίσουμε τη διαδικασία, το όριο που θα προκύψει θα είναι η τρισδιάστατη καμπύλη Peano.

 

Το παρακάτω video δείχνει το 1ο βήμα της κατασκευής. Προσέξετε πως οι 27 μικρότερες πολυγωνικές γραμμές ενώνονται μεταξύ τους.

Το παρακάτω video δείχνει το 2ο βήμα της κατασκευής. Εδώ έχουμε 729 μικρότερους κύβους.

 

Παρακάτω δίνουμε τον απαραίτητο κώδικα σε matlab για την κατασκευή της τρισδιάστατης καμπύλης Peano.

%Created by www.mathstudies.eu %This function creates and plots a 3D version of the Peano curve after n %iterations %------------------------------------------------------------------- %Input: %n: is the number of iterations %------------------------------------------------------------------- %Output %The function outputs the vectors X and Y %X: is the vector with the x-coordinates of the points of the Peano Curve %Y: is the vector with the y-coordinates of the points of the Peano Curve %Z: is the vector with the y-coordinates of the points of the Peano Curve % %Moreover, the function plots the curve using line(X,Y,'Color','b'). %The function uses the Deterministic Iteation Algorithm for fractal %construction (it is given as a function below) function [X,Y,Z] = PeanoCurve3D( n ) W=[ 1/3 0 0 0 1/3 0 0 0 1/3 0 0 0; -1/3 0 0 0 1/3 0 0 0 -1/3 1/3 1/3 1/3; 1/3 0 0 0 1/3 0 0 0 1/3 0 2/3 0; 1/3 0 0 0 -1/3 0 0 0 -1/3 1/3 1 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 1/6 5/6 5/6; 1/2 5/6 5/6; 1/2 1/6 5/6; 5/6 1/6 5/6; 5/6 5/6 5/6; ]; %with DIA Pea=MYDIA_R2_fast(A0,W,number_of_maps,n); X=Pea(:,1); Y=Pea(:,2); Z=Pea(:,3); plot3(X,Y,Z,'Color','r'); xlim([0,1]); ylim([0,1]); zlim([0,1]); grid on; az = 60; el = 20; view(az, el); %A0 is the initial set represented by a Mx2 matrix %N is the number of the mappings %K is the number of iterations %W is the matrix Nx6 containing the parameters of the mappings %Each row (i) contains the 12 coefficients of the map w_i. a,b,c,s,d,e % / \ / \ % |a b c| | j | %w=| | | | % |d e f| + | k | % | | | | % |g h i| | l | % \ / \ / %The function returns the matrix FP N^K x 3!!! function B=MYDIA_R2_fast(A0,W,N,K) A=A0; [M,l]=size(A0); points=M; if (K==0) B = A0; end; maps = length(W(:,1)); for i=1:K %iterations B = zeros(points*N,3); for j=1:maps W_map = [W(j,1) W(j,2) W(j,3); W(j,4) W(j,5) W(j,6); W(j,7) W(j,8) W(j,9)]'; Add_map = repmat([W(j,10) W(j,11) W(j,12)],points,1); B(1+(j-1)*points:j*points,:) = A*W_map + Add_map; end; points=M*N^i; if (i<K) A=B; end; end;

 

Αν θέλουμε να αναπαραστήσουμε την κατασκευή όπως στα video, τότε πρέπει να χρησιμοποιήσουμε τις εντολές VideoWriter και writeVideo του matlab. Προσθέστε τις παρακάτω εντολές στο τέλος της βασικής συνάρτησης PeanoCurve3D.

figure(2); hold on; xlim([0,1]); ylim([0,1]); zlim([0,1]); az = 45; el = 45; view(az, el); colormap jet(81); cmap = colormap; L = length(X(:,1)); file = VideoWriter('peano3d.avi'); open(file); for k = 1:length(X(:,1))-1 pause(0.001); plot3(X(k:k+1,1),Y(k:k+1,1),Z(k:k+1,1),

'Color',cmap(mod(k,81)+1,:),'LineWidth',2); drawnow; Fr=getframe; writeVideo(file,Fr); end close(file);

Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

Σχετικοί Σύνδεσμοι

bottom of page