-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake_motif.m
102 lines (76 loc) · 2.52 KB
/
make_motif.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function motif = make_motif( tile, group )
% motif = make_wallpaper( tile, group )
% Creates a 2D image wallpaper motif given an m x n image patch
% and a specified wallpaper group type.
%
% tile : m x n sparse matrix
%
% motif : sparse matrix
%
% Written by Rick Gilmore, [email protected]
%
% Released under GPLv3
%--------------------------------------------------------------------------
%
% History
%
% 2013-04-21 rog wrote
%--------------------------------------------------------------------------
%
% Development notes
%
% 2013-04-21 Need to add and test code for complete set of 17 Wallpaper
% groups.
% Input parameter checking
if ~ischar( group )
error('Group must be a string.');
end
% Test tile
% For each group, transform tile, then assemble motif from transformed
% components
switch group
case {'p1', 'P1'}
motif = tile;
case {'p2', 'P2'} % Add Conway terms
r180 = transform_tile( tile, 'rotate-180');
motif = [ tile r180 ];
case {'pm', 'PM'}
mh = transform_tile( tile, 'mirror-h');
motif = [ mh;
tile ];
case {'pg', 'PG'}
mv = transform_tile( tile, 'mirror-v');
motif = [ tile;
mv ];
case {'cm', 'CM'}
mv = transform_tile( tile, 'mirror-v');
motif = [ tile mv tile mv;
mv tile mv tile ];
case { 'pmm', 'PMM' }
mv = transform_tile( tile, 'mirror-v');
mh = transform_tile( tile, 'mirror-v');
mb = transform_tile( tile, 'mirror-hv');
motif = [ tile mv;
mh mb ];
case { 'pmg', 'PMG' }
mv = transform_tile( tile, 'mirror-v');
mh = transform_tile( tile, 'mirror-v');
mb = transform_tile( tile, 'mirror-hv');
motif = [ mb tile;
mv mh ];
case { 'p4', 'P4' }
r270 = transform_tile( tile, 'rotate-270' );
r180 = transform_tile( tile, 'rotate-180' );
r90 = transform_tile( tile, 'rotate-90' );
motif = [ tile r270;
r90 r180 ];
case { 'p4m', 'P4M' }
r270 = transform_tile( tile, 'rotate-270' );
r180 = transform_tile( tile, 'rotate-180' );
r90 = transform_tile( tile, 'rotate-90' );
motif = [ tile r270;
r90 r180 ];
otherwise
error('Wallpaper group value not supported.');
end
return