How to create a periodic pattern from two or more periodic data sets?

8 views (last 30 days)
I want to create moiré fringes generated from two periodic sets (A, B) of points as shown in the attcahed. I have tried this script to generate the hexagonal array. I want to control the size and shape of the repeating units (highlighted by black boxd regions in the figure attached) by varying the dimensions (e.g., sides and angles) of these units for A and B. Finally, I want to generate stacks of A and B data points to create moire fringes for various twist angles (0example shows 10 degree twist). I tried the following code. Is there a way to highlight only the peaks in the 2D array such that the plot becomes less cluttered? How do I enlarge the field-of-view without having to compromise visualizing the moire period clearly?
numRows = 10; % Number of rows in the hexagonal lattice
numCols = 10; % Number of columns in the hexagonal lattice
periodicity1 = 4; % Periodicity of the first array
periodicity2 = 12; % Periodicity of the second array
twistAngle = 10; % Twist angle in degrees
% Create hexagonal lattice for array with periodicity 5
[X1, Y1] = meshgrid(1:numCols, 1:numRows);
X1 = X1 + 0.5 * mod(Y1, 2); % Shift every other row
scalarValues1 = mod(X1 + Y1, periodicity1);
% Create hexagonal lattice for array with periodicity 10
[X2, Y2] = meshgrid(1:numCols, 1:numRows);
X2 = X2 + 0.5 * mod(Y2, 2); % Shift every other row
scalarValues2 = mod(X2 + Y2, periodicity2);
% Apply twist to the second array
theta = deg2rad(twistAngle);
X2_twisted = X2 * cos(theta) - Y2 * sin(theta);
Y2_twisted = X2 * sin(theta) + Y2 * cos(theta);
% Generate scatter plots for both arrays
figure;
subplot(1, 3, 1);
scatter(X1(:), Y1(:), 100, scalarValues1(:), 'filled','o');
axis equal;
colorbar;
title('Array with Periodicity X');
xlabel('X');
ylabel('Y');
subplot(1, 3, 2);
scatter(X2_twisted(:), Y2_twisted(:), 100, scalarValues2(:), 'filled');
axis equal;
colorbar;
title('Array with Periodicity Y and Twist');
xlabel('X');
ylabel('Y');
subplot(1, 3, 3);
scatter(X2_twisted(:), Y2_twisted(:), 100, scalarValues2(:), 'filled');
hold on
scatter(X1(:), Y1(:), 100, scalarValues1(:), 'filled','o');
axis equal;
colorbar;
title('Array with Moiré Periodicity');
xlabel('X');
ylabel('Y');
Next, I want to generate the contour frequency plots corresponding to the moiré periodicity for each twisted structures. Ideally something like the following would be the outcome. Can you help me adjust my script such that it can fit (cosine) the moire period generated by the above script? Thank you for your help!
LengthX = .03; % X Length of sample in mm
LengthY = .03; % Y Length of sample in mm
X_k =2; % Number of Periods along X
Y_k =1; % Number of Periods along Y
T1=.01; % 10mm
T2=.02; % 20mm
f1=1/T1; % Frequency 1
f2=1/T2; % Frequency 2
StepSize = 0.0005; % Evenly Spaced X,Y gridpoints
x = 0:StepSize:LengthX;
y = 0:StepSize:LengthY;
[X,Y] = meshgrid(x,y);
Z = sin(2*pi*f1*X)+sin(2*pi*f2*Y);
figure
surf(x,y,Z) %Plot 2D PES

Answers (0)

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!