Skip to content

Commit b16a842

Browse files
committed
Initial commit of files from File Exchange, plus new README.md file
0 parents  commit b16a842

20 files changed

+670
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[![View Pixel Grid on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/69490-penrose-rhombus-tiling)
2+
3+
# Penrose Rhombus Tiling
4+
5+
This repository contains MATLAB functions for visualizing a type of Penrose tiling. Penrose tilings are non-periodic and self-similar. The particular tiling implemented here, called P3, is constructed from a pair of rhombuses, a thin one and a thick one.
6+
7+
![](doc/penrose-screen-shot.png)
8+
9+
Copyright 2019 The MathWorks, Inc.

aTriangle.m

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function t = aTriangle(Apex,Left,Right)
2+
%aTriangle Representation of type A triangle in table form.
3+
% t = aTriangle(apex,left,right) returns a type A triangle represented as
4+
% a one-row table. The triangle vertices (apex, left, and right) are
5+
% complex numbers. If one of the triangle vertices is empty, it is
6+
% computed automatically.
7+
%
8+
% EXAMPLE
9+
% Compute a type A triangle with apex at (0,1) and left base vertex at
10+
% (0,0) in the complex plane.
11+
%
12+
% t = aTriangle(1i,0,[])
13+
14+
% Copyright 2018 The MathWorks, Inc.
15+
16+
[Apex,Left,Right] = isoscelesTriangle(Apex,Left,Right,36);
17+
Type = categorical("A");
18+
t = table(Apex,Left,Right,Type);

apTriangle.m

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function t = apTriangle(Apex,Left,Right)
2+
%aTriangle Representation of type A-prime triangle in table form.
3+
% t = aTriangle(apex,left,right) returns a type A-prime triangle
4+
% represented as a one-row table. The triangle vertices (apex, left, and
5+
% right) are complex numbers. If one of the triangle vertices is empty,
6+
% it is computed automatically.
7+
%
8+
% EXAMPLE
9+
%
10+
% Compute a type A-prime triangle with apex at (0,1) and left base vertex
11+
% at (0,0) in the complex plane.
12+
%
13+
% t = apTriangle(1i,0,[])
14+
15+
% Copyright 2018 The MathWorks, Inc.
16+
17+
[Apex,Left,Right] = isoscelesTriangle(Apex,Left,Right,36);
18+
Type = categorical("Ap");
19+
t = table(Apex,Left,Right,Type);

bTriangle.m

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function t = bTriangle(Apex,Left,Right)
2+
%bTriangle Representation of type B triangle in table form.
3+
% t = bTriangle(apex,left,right) returns a type B triangle represented as
4+
% a one-row table. The triangle vertices (apex, left, and right) are
5+
% complex numbers. If one of the triangle vertices is empty, it is
6+
% computed automatically.
7+
%
8+
% EXAMPLE
9+
% Compute a type B triangle with apex at (0,1) and left base vertex at
10+
% (0,0) in the complex plane.
11+
%
12+
% t = bTriangle(1i,0,[])
13+
14+
% Copyright 2018 The MathWorks, Inc.
15+
16+
[Apex,Left,Right] = isoscelesTriangle(Apex,Left,Right,108);
17+
Type = categorical("B");
18+
t = table(Apex,Left,Right,Type);

bpTriangle.m

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function t = bpTriangle(Apex,Left,Right)
2+
%bpTriangle Representation of type B-prime triangle in table form.
3+
% t = bpTriangle(apex,left,right) returns a type B-prime triangle
4+
% represented as a one-row table. The triangle vertices (apex, left, and
5+
% right) are complex numbers. If one of the triangle vertices is empty,
6+
% it is computed automatically.
7+
%
8+
% EXAMPLE
9+
%
10+
% Compute a type B-prime triangle with apex at (0,1) and left base vertex
11+
% at (0,0) in the complex plane.
12+
%
13+
% t = bpTriangle(1i,0,[])
14+
15+
% Copyright 2018 The MathWorks, Inc.
16+
17+
[Apex,Left,Right] = isoscelesTriangle(Apex,Left,Right,108);
18+
Type = categorical("Bp");
19+
t = table(Apex,Left,Right,Type);

decomposeATriangle.m

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function out = decomposeATriangle(in)
2+
%decomposeATriangle Decompose type A triangle.
3+
%
4+
% t = decomposeATriangle(in) decomposes a type A triangle into a type A
5+
% and a type B-prime triangle. The input is a one-row table as returned
6+
% by aTriangle, and the output is a two-row table.
7+
8+
% Copyright 2018 The MathWorks, Inc.
9+
10+
out = [ ...
11+
aTriangle(in.Left,in.Right,[])
12+
bpTriangle([],in.Apex,in.Left) ];

decomposeApTriangle.m

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function out = decomposeApTriangle(in)
2+
%decomposeApTriangle Decompose type A-prime triangle.
3+
%
4+
% t = decomposeApTriangle(in) decomposes a type A-prime triangle into a
5+
% type A-prime and a type B triangle. The input is a one-row table as
6+
% returned by apTriangle, and the output is a two-row table.
7+
8+
% Copyright 2018 The MathWorks, Inc.
9+
10+
out = [ ...
11+
apTriangle(in.Right,[],in.Left)
12+
bTriangle([],in.Right,in.Apex) ];

decomposeBTriangle.m

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function out = decomposeBTriangle(in)
2+
%decomposeBTriangle Decompose type B triangle.
3+
%
4+
% t = decomposeBTriangle(in) decomposes a type B triangle into a type A
5+
% triangle, a type B triangle, and a type B-prime triangle. The input is
6+
% a one-row table as returned by bTriangle, and the output is a three-row
7+
% table.
8+
9+
% Copyright 2018 The MathWorks, Inc.
10+
11+
t_b = bTriangle([],in.Right,in.Apex);
12+
t_a = aTriangle(t_b.Apex,in.Apex,[]);
13+
t_bp = bpTriangle(t_a.Right,in.Left,t_a.Apex);
14+
15+
out = [t_b ; t_a ; t_bp];
16+

decomposeBpTriangle.m

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function out = decomposeBpTriangle(in)
2+
%decomposeBpTriangle Decompose type B-prime triangle.
3+
%
4+
% t = decomposeBpTriangle(in) decomposes a type B-prime triangle into a
5+
% type B-prime triangle, a type A-prime triangle, and a type B triangle.
6+
% The input is a one-row table as returned by bpTriangle, and the output
7+
% is a three-row table.
8+
9+
% Copyright 2018 The MathWorks, Inc.
10+
11+
t_bp = bpTriangle([],in.Apex,in.Left);
12+
t_ap = apTriangle(t_bp.Apex,[],in.Apex);
13+
t_b = bTriangle(t_ap.Left,t_ap.Apex,in.Right);
14+
15+
out = [t_bp ; t_ap ; t_b];
16+
17+

decomposeTriangles.m

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function out = decomposeTriangles(in)
2+
%decomposeTriangles Decompose a table of A, A', B, and B' triangles.
3+
%
4+
% decomposeTriangles decomposes each triangle in the input table and
5+
% returns all the decomposed triangles together as a new table.
6+
%
7+
% EXAMPLE
8+
% Starting with an A triangle, successively apply triangle
9+
% decomposition three times and display the result.
10+
%
11+
% t = aTriangle(1i,0,[]);
12+
% for k = 1:3
13+
% t = decomposeTriangles(t);
14+
% end
15+
% showLabeledTriangles(t)
16+
17+
% Copyright 2018 The MathWorks, Inc.
18+
19+
c = cell(height(in),1);
20+
21+
for k = 1:height(in)
22+
t_k = in(k,:);
23+
24+
switch in.Type(k)
25+
case "A"
26+
c{k} = decomposeATriangle(t_k);
27+
28+
case "Ap"
29+
c{k} = decomposeApTriangle(t_k);
30+
31+
case "B"
32+
c{k} = decomposeBTriangle(t_k);
33+
34+
case "Bp"
35+
c{k} = decomposeBpTriangle(t_k);
36+
end
37+
end
38+
39+
out = cat(1,c{:});

doc/PenroseRhombusTiling.mlx

628 KB
Binary file not shown.

0 commit comments

Comments
 (0)