-
Notifications
You must be signed in to change notification settings - Fork 0
/
Symmetry.elm
116 lines (91 loc) · 2.61 KB
/
Symmetry.elm
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
103
104
105
106
107
108
109
110
111
112
module Symmetry exposing (h4)
import Math.Matrix4 as Mat4 exposing (Mat4,mul)
import Matrices exposing (fromTuples, spin, moveForward)
-- The purpose of this module is to generate a list of all 7200 elements of the chiral hexacosichoric group.
-- Sadly, I do not know of a nice way of doing this.
type alias Symmetries = List Mat4
id = Mat4.identity
phi : Float
phi = (sqrt 5 + 1) / 2
triangular : Symmetries
triangular =
let rot1 = fromTuples
( (0,0,1,0)
, (1,0,0,0)
, (0,1,0,0)
, (0,0,0,1))
in
[ id
, rot1
, mul rot1 rot1
]
symmX =
[ id
, fromTuples
( ( 1, 0, 0,0)
, ( 0,-1, 0,0)
, ( 0, 0,-1,0)
, ( 0, 0, 0,1)
)
]
symmY =
[ id
, fromTuples
( (-1, 0, 0,0)
, ( 0, 1, 0,0)
, ( 0, 0,-1,0)
, ( 0, 0, 0,1)
)
]
rotateIntoPentPlane : Mat4
rotateIntoPentPlane =
Matrices.turnUp (atan (1/phi))
rotateOutOfPentPlane : Mat4
rotateOutOfPentPlane =
Matrices.turnUp (atan (-1/phi))
combineSymms : Symmetries -> Symmetries -> Symmetries
combineSymms a b = List.concatMap (\a -> List.map (mul a) b) a
tetrahedral : Symmetries
tetrahedral = combineSymms (combineSymms symmX symmY) triangular
h3pentplane : Symmetries
h3pentplane = combineSymms (combineSymms tetrahedral [rotateIntoPentPlane]) pentagonal
h3 : Symmetries
h3 = combineSymms h3pentplane [rotateOutOfPentPlane]
pentagonal : Symmetries
pentagonal =
let rot n = spin (2*pi*n/5)
in List.map (rot << toFloat) (List.range 0 4)
column : Symmetries
column =
let rot n = mul (moveForward (pi*n/5)) (spin (pi*n/5))
in List.map (rot << toFloat) (List.range 0 9)
column2 : Symmetries
column2 = combineSymms h3pentplane column
nextColumn : Mat4
nextColumn =
Mat4.mul rotateOutOfPentPlane
<| Mat4.mul rotateOutOfPentPlane
<| Mat4.mul (moveForward (pi/5))
<| Mat4.mul (spin (4*pi/5))
<| Mat4.mul rotateOutOfPentPlane
<| Mat4.mul rotateOutOfPentPlane
<| spin pi
h4 : Symmetries
h4 =
let a = nextColumn
b = Mat4.mul nextColumn nextColumn
in [ id -- our column
, a -- neigboring columns
, Mat4.mul a (spin (2*pi/5))
, Mat4.mul a (spin (4*pi/5))
, Mat4.mul a (spin (6*pi/5))
, Mat4.mul a (spin (8*pi/5))
, b -- neigboring colums of antipode
, Mat4.mul b (spin (2*pi/5))
, Mat4.mul b (spin (4*pi/5))
, Mat4.mul b (spin (6*pi/5))
, Mat4.mul b (spin (8*pi/5))
-- antipode
, Mat4.mul a (Mat4.mul (spin (2*pi/5)) b)
]
|> combineSymms column2