Skip to content

Commit 09e7da8

Browse files
committed
autoformat code
1 parent 97451d8 commit 09e7da8

File tree

4 files changed

+41
-40
lines changed

4 files changed

+41
-40
lines changed

lib/m/SelfAffine2D.m

+8-14
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
%% settings
77
% IFS linear parts
88
linearMats = {[0.25 0; 0 0.25], ...
9-
[0.25 0; 0 0.25], ...
10-
[0.25 0; 0 0.25], ...
11-
[0.25 0; 0 0.25], ...
12-
[0.5 0; 0 0.5]};
9+
[0.25 0; 0 0.25], ...
10+
[0.25 0; 0 0.25], ...
11+
[0.25 0; 0 0.25], ...
12+
[0.5 0; 0 0.5]};
1313

1414
% IFS translations
1515
translations = {[0; 0], ...
16-
[0.75; 0], ...
16+
[0.75; 0], ...
1717
[0.75; 0.75], ...
1818
[0; 0.75], ...
1919
[0.25; 0.25]};
2020

2121
% initial polygon for iteration
2222
shapeInit = [0 1 1 0;
23-
0 0 1 1];
23+
0 0 1 1];
2424

2525
numItrs = 5; % iteration time
2626

@@ -43,7 +43,6 @@
4343
% translations = {[0; 0], [cRatio; 0], [0; cRatio]};
4444
% shapeInit = [0 1 0; 0 0 1];
4545

46-
4746
% % Sierpinski gasket (self-affine)
4847
% hRatio = 0.25;
4948
% vRatio = 0.7;
@@ -62,7 +61,6 @@
6261
% translations = {[0;0], [1;0], [2;0], [0;1], [2;1], [0;2], [1;2], [2;2]};
6362
% shapeInit = [0 3 3 0; 0 0 3 3];
6463

65-
6664
% % Bedford-McMullen carpet
6765
% BMh = 3; % horizontal size
6866
% BMv = 4; % vertical size
@@ -82,7 +80,6 @@
8280
% end
8381
% shapeInit = [0 1 1 0; 0 0 1 1];
8482

85-
8683
% % Baranski carpet (with possible overlaps)
8784
% Bar_h = [0.1 0.3 0.4 0.2]; % horizontal scales
8885
% Bar_v = [0.1 0.2 0.4 0.3]; % vertical scales
@@ -112,7 +109,6 @@
112109
% translations = {[0; 0], [1-cRatio; 0], [0.5*(1-cRatio); (1-cRatio)*0.5*sqrt(3)]};
113110
% shapeInit = [0 1 0.5; 0 0 0.5*sqrt(3)];
114111

115-
116112
% % Sierpinski triangle (self-affine)
117113
% ratio1st = 2/3;
118114
% ratio2nd = 2/3;
@@ -139,7 +135,6 @@
139135
% [0.5; 0.75]};
140136
% shapeInit = [0 1 1 0; 0 0 1 1];
141137

142-
143138
% % product Cantor set
144139
% linearMats = cell(1, 4);
145140
% for i = 1:4
@@ -161,7 +156,6 @@
161156
% translations = {[0; 0], [0.75; 0], [0.75; 0.75], [0; 0.75], [0.25; 0.25]};
162157
% shapeInit = [0 1 1 0; 0 0 1 1];
163158

164-
165159
%% Error handling
166160
isCompactible = false;
167161

@@ -207,8 +201,8 @@
207201
facesPlot = kron(ones(numShapes, 1), shapeInitFaces) + ...
208202
kron((0:(numShapes - 1))' * numInitPts, ones(numInitFaces, 1));
209203
figure(1)
210-
patch('Faces', facesPlot,...
211-
'Vertices', ptsNow' , ...
204+
patch('Faces', facesPlot, ...
205+
'Vertices', ptsNow', ...
212206
'FaceColor', colorFaces, ...
213207
'EdgeColor', colorEdges, ...
214208
'FaceAlpha', alphaFaces)

lib/m/SelfAffine3D.m

+9-10
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
%% settings
77
% IFS linear parts
8-
linearMats = {diag([1/6, 1/4, 1/3]),...
9-
diag([1/2, 1/2, 1/3]),...
10-
diag([1/3, 1/4, 2/3]),...
11-
diag([1/2, 1/4, 1/3])};
8+
linearMats = {diag([1/6, 1/4, 1/3]), ...
9+
diag([1/2, 1/2, 1/3]), ...
10+
diag([1/3, 1/4, 2/3]), ...
11+
diag([1/2, 1/4, 1/3])};
1212

1313
% IFS translations
14-
translations = {[0 0 0]',...
15-
[1/6 1/4 0]',...
16-
[2/3, 3/4, 1/3]',...
14+
translations = {[0 0 0]', ...
15+
[1/6 1/4 0]', ...
16+
[2/3, 3/4, 1/3]', ...
1717
[1/6, 0, 0]'};
1818

1919
% initial polyhedron for iteration
@@ -44,7 +44,6 @@
4444
% shapeInit = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1]';
4545
% shapeInitFaces = [4 8 5 1; 1 5 6 2; 2 6 7 3; 3 7 8 4; 5 8 7 6; 1 4 3 2];
4646

47-
4847
% % Sierpinski-Menger sponge
4948
% ratio = 1/3;
5049
% linearMats = cell(20, 1);
@@ -65,7 +64,6 @@
6564
% shapeInit = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1]';
6665
% shapeInitFaces = [4 8 5 1; 1 5 6 2; 2 6 7 3; 3 7 8 4; 5 8 7 6; 1 4 3 2];
6766

68-
6967
% % Baranski menger
7068
% linearMats = {diag([1/6, 1/4, 1/3]),...
7169
% diag([1/2, 1/2, 1/3]),...
@@ -91,7 +89,6 @@
9189
% shapeInit = [0 0 0; 1 0 0; 1/2 sqrt(3)/2 0; 1/2 1/sqrt(12) sqrt(6)/3]';
9290
% shapeInitFaces = [1 2 3; 1 2 4; 1 3 4; 2 3 4];
9391

94-
9592
%% Error handling
9693
isCompactible = false;
9794

@@ -149,6 +146,7 @@
149146

150147
if showFirstItrs && numItrs >= numFirstItrs
151148
figure(2)
149+
152150
for i = 1:numFirstItrs
153151
subplot(1, numFirstItrs, i)
154152
sizeTmp = size(ptsTotal{i}, 2);
@@ -164,6 +162,7 @@
164162
set(gca, 'XColor', 'none', 'YColor', 'none', 'ZColor', 'none')
165163
% title(['Iteration time = ', num2str(i-1)], 'Interpreter', 'latex');
166164
end
165+
167166
end
168167

169168
%% Show param

lib/m/SelfSimilar1D.m

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
% trans = [0, 2/3];
2424
% intervalInit = [0, 1];
2525

26-
2726
% % a classic example
2827
% ratios = [1/2, 1/3, 1/4];
2928
% trans = [0, 1/3, 3/4];
3029
% intervalInit = [0, 1];
3130

32-
3331
%% prepare params & error handling
3432
isCompact = false;
33+
3534
if length(ratios) == length(trans)
3635
isCompact = true;
3736
end
37+
3838
if ~isCompact
3939
error('Illegal settings. Dimensions of the parameters does not match!')
4040
end
@@ -54,10 +54,12 @@
5454

5555
for levelNow = 1:numItrs
5656
ptsTmp = zeros(spaceDim, sizeNow * sizeIFS);
57+
5758
for indexFct = 1:sizeIFS
5859
ptsTmp((indexFct - 1) * sizeNow + 1:indexFct * sizeNow) = ...
5960
ratios(indexFct) * ptsNow + trans(indexFct);
6061
end
62+
6163
ptsNow = ptsTmp;
6264
sizeNow = length(ptsNow);
6365
ptsTotal{levelNow + 1} = ptsNow;
@@ -68,7 +70,7 @@
6870
numSegments = size(ptsPlt, 2);
6971

7072
figure(1)
71-
plot(ptsPlt,...
73+
plot(ptsPlt, ...
7274
zeros(2, numSegments), ...
7375
color, "LineWidth", thickness)
7476
set(gca, 'XColor', 'none', 'YColor', 'none')
@@ -79,18 +81,22 @@
7981

8082
if showFirstItrs && numItrs + 1 >= numFirstItrs
8183
figure(2)
84+
8285
for i = 1:numFirstItrs
8386
ptsPltTmp = reshape(ptsTotal{i}, 2, []);
8487
numSegmentsTmp = size(ptsPltTmp, 2);
8588
plot(ptsPltTmp, zeros(2, numSegmentsTmp) - i, ...
86-
color, "LineWidth", thickness)
89+
color, "LineWidth", thickness)
8790
hold on
8891
end
92+
8993
hold off
9094
set(gca, 'XColor', 'none', 'YColor', 'none', 'ZColor', 'none')
95+
9196
if showTitle
92-
title(['Iteration time = ', num2str(numFirstItrs - 1 )], 'Interpreter', 'latex');
97+
title(['Iteration time = ', num2str(numFirstItrs - 1)], 'Interpreter', 'latex');
9398
end
99+
94100
ylim([- numFirstItrs - 0.5 * thickness / 50, 0])
95101
end
96102

lib/m/SelfSimilar1DHomo.m

+13-11
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,19 @@
2929
% trans = [0, 2/3];
3030
% intervalInit = [0, 1];
3131

32-
3332
% % lambda Cantor set
3433
% numMaps = 3;
3534
% ratio = 1/3;
3635
% lambda = 1/2;
3736
% trans = [0, 2/3, lambda / 3];
3837
% intervalInit = [0, 1];
3938

40-
4139
% % Bernoulli convolutions
4240
% numMaps = 2;
4341
% ratio = 0.4;
4442
% trans = [0, 1 - ratio];
4543
% intervalInit = [0, 1];
4644

47-
4845
% % an example
4946
% numMaps = 5;
5047
% a = 3;
@@ -54,9 +51,11 @@
5451

5552
%% prepare params & error handling
5653
isCompact = false;
54+
5755
if numMaps == length(trans)
5856
isCompact = true;
5957
end
58+
6059
if ~isCompact
6160
error('Illegal settings. Dimensions of the parameters does not match!')
6261
end
@@ -81,15 +80,15 @@
8180
end
8281

8382
%% plot
84-
lenBasic = ratio ^ numItrs * lenInit;
83+
lenBasic = ratio^numItrs * lenInit;
8584
ptsDiff = diff(ptsNow);
8685
indexGaps = ptsDiff > lenBasic;
8786
ptsLeft = ptsNow([true indexGaps]);
8887
numSegments = length(ptsLeft);
8988
ptsRight = [ptsNow([false, indexGaps]) - ptsDiff(indexGaps), ptsNow(end)] + lenBasic;
9089

9190
figure(1)
92-
plot([ptsLeft; ptsRight],...
91+
plot([ptsLeft; ptsRight], ...
9392
zeros(2, numSegments), ...
9493
color, "LineWidth", thickness)
9594
set(gca, 'XColor', 'none', 'YColor', 'none')
@@ -100,28 +99,31 @@
10099

101100
if showFirstItrs && numItrs + 1 >= numFirstItrs
102101
figure(2)
102+
103103
for i = 1:numFirstItrs
104-
lenBasicTmp = ratio ^ (i-1) * lenInit;
104+
lenBasicTmp = ratio^(i - 1) * lenInit;
105105
ptsDiffTmp = diff(ptsTotal{i});
106106
indexGapsTmp = ptsDiffTmp > lenBasicTmp;
107107
ptsLeftTmp = ptsTotal{i}([true indexGapsTmp]);
108108
numSegmentsTmp = length(ptsLeftTmp);
109-
ptsRightTmp = [ptsTotal{i}([false, indexGapsTmp]) - ptsDiffTmp(indexGapsTmp),...
110-
ptsTotal{i}(end)] + lenBasicTmp;
111-
plot([ptsLeftTmp; ptsRightTmp],...
109+
ptsRightTmp = [ptsTotal{i}([false, indexGapsTmp]) - ptsDiffTmp(indexGapsTmp), ...
110+
ptsTotal{i}(end)] + lenBasicTmp;
111+
plot([ptsLeftTmp; ptsRightTmp], ...
112112
zeros(2, numSegmentsTmp) - i, ...
113113
color, "LineWidth", thickness)
114114
hold on
115115
end
116+
116117
hold off
117118
set(gca, 'XColor', 'none', 'YColor', 'none', 'ZColor', 'none')
119+
118120
if showTitle
119-
title(['Iteration time = ', num2str(numFirstItrs - 1 )], 'Interpreter', 'latex');
121+
title(['Iteration time = ', num2str(numFirstItrs - 1)], 'Interpreter', 'latex');
120122
end
123+
121124
ylim([- numFirstItrs - 0.5 * thickness / 50, 0])
122125
end
123126

124-
125127
%% show param
126128
countPtsTotal = sizeNow;
127129
countShapesTotal = size(ptsLeft, 2);

0 commit comments

Comments
 (0)