-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepresentD3.m
55 lines (51 loc) · 1.41 KB
/
RepresentD3.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
function M = RepresentD3(r,s)
%Gives the irreducible representation of an element of D_3, the symmetries
%of an equilateral triangle
% Input:
% r: Number of rotations a third of the way around the triangle
% Must be 0,1 or 2
% s: Number of flips of the triangle
% Must be 0 or 1
% Output:
% M: Matrix which is an irreducible representation of the input
if (r ~= 0) && (r ~= 1) && (r ~= 2)
error('Invalid number of rotations (r)');
elseif (s ~= 0) && (s ~= 1)
error('Invalid number of flips (s)');
end
M = eye(4);
switch r
case 0
if (s == 1)
M(2,2) = -1;
M(3,3) = 1/2;
M(3,4) = -1/2 * sqrt(3);
M(4,3) = -1/2 * sqrt(3);
M(4,4) = -1/2;
end
case 1
switch s
case 0
M(3,3) = -1/2;
M(3,4) = -1/2 * sqrt(3);
M(4,3) = 1/2 * sqrt(3);
M(4,4) = -1/2;
case 1
M(2,2) = -1;
M(3,3) = -1;
end
case 2
switch s
case 0
M(3,3) = -1/2;
M(3,4) = 1/2 * sqrt(3);
M(4,3) = -1/2 * sqrt(3);
M(4,4) = -1/2;
case 1
M(2,2) = -1;
M(3,3) = 1/2;
M(3,4) = 1/2 * sqrt(3);
M(4,3) = 1/2 * sqrt(3);
M(4,4) = -1/2;
end
end