-
Notifications
You must be signed in to change notification settings - Fork 6
/
polytopes.html
1717 lines (1510 loc) · 66 KB
/
polytopes.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>Polytopes and Coxeter Groups</title>
<link rel='stylesheet' href='style.css' type='text/css' />
<link rel='stylesheet' href='datgui.css' type='text/css' />
<link href="https://fonts.googleapis.com/css?family=Cinzel+Decorative" rel="stylesheet">
</head>
<body>
<script src="js/three.min.js" type="text/javascript"></script>
<script src="js/OrbitControls.js" type="text/javascript"></script>
<script src="js/Detector.js" type="text/javascript"></script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.4/svg.js" integrity="sha256-Vfh4R0uOWH2tv2NrGrtTZUo+hRBMGtEczBeTz3CSvj4="
crossorigin="anonymous"></script>
<script src="toddcoxeter.js" type="text/javascript"></script>
<script src="utils.js" type="text/javascript"></script>
<script src="js/dat.gui.min.js" type="text/javascript"></script>
<script>
var showSceneObjects;
</script>
<div class="header">
<h1>Building 4D polytopes</h1>
<div class="author">by Mikael Hvidtfeldt Christensen,
<a href="https://twitter.com/syntopiadk?lang=en">@SyntopiaDK</a>
</div>
<p>Years ago I stumbled upon the
<a href="http://blog.hvidtfeldts.net/index.php/2012/02/distance-estimated-polychora/">convex regular 4-polytopes</a> - four-dimensional analogues of the Platonic solids. I did not understand the mathematics
behind these structures back then - but recently I decided to figure out how this works.
</p>
<p>
<em>This page is not mobile friendly. While some content might be viewable, the WebGL stuff will likely not work. The page
is best viewed with Chrome, and with a discrete GPU enabled (for the ray traced stuff).
</em>
</p>
</div>
<div class="mainContent" id="main">
<p>
My first encounter with four-dimensional polytopes was
<a href="https://www.math.cmu.edu/~fho/jenn/">Jenn 3D</a> (2001-2007) by
<a href="http://fritzo.org/">Fritz Obermeyer</a>. Jenn describes itself as follows:</p>
<p>
<em>Jenn is a toy for playing with various quotients of Cayley graphs of finite Coxeter groups on four generators. Jenn builds
the graphs using the Todd-Coxeter algorithm, embeds them into the 3-sphere, and stereographically projects them onto
Euclidean 3-space.
</em>
</p>
<p>
Wow. This description made absolutely no sense to me when I first read it - none of these terms were familiar to me. My
purpose with this page is to go through this description step-by-step and explain the various terms.
</p>
<p>
We will also go one step further, and discuss how these structures can be ray traced in realtime. This can be done using a
clever (inverse) construction technique of
<em>folding</em> space into a fundamental domain. The technique was originally described by
<a href="https://plus.google.com/114982179961753756261">Abdelaziz Nait Merzouk</a> (aka Knighty) in a
<a href="http://www.fractalforums.com/fragmentarium/solids-many-many-solids/">Fractal Forums thread</a> from 2012.
</p>
<div class="fullwidth">
<img src="img3.jpg" width="100%" />
</div>
<h2>Symmetries of the cube</h2>
<p>
We will start out in three dimensions with a familiar object: the cube. </p>
<div class="rightBox" id="rboxSimple">
</div>
<script>
function sceneAdd(scene, object, group) {
if (scene.groupings == undefined) {
scene.groupings = new Map();
}
if (scene.groupings.get(group) == undefined) {
scene.groupings.set(group, []);
}
scene.groupings.get(group).push(object);
scene.add(object);
}
init();
function init() {
var d = document.getElementById("rboxSimple");
var scene = getStandard3DView(d, getSideWidth(), getSideWidth());
var v = getVertices();
var e = getEdges();
scene.add(createPlane(v[0], v[1], v[3], 0xff0000)); // top
scene.add(createPlane(v[5], v[6], v[4], 0xff0000)); // bottom
scene.add(createPlane(v[3], v[2], v[7], 0x00ff00)); // right
scene.add(createPlane(v[0], v[1], v[4], 0x00ff00)); // left
scene.add(createPlane(v[0], v[3], v[4], 0x0000ff)); // front
scene.add(createPlane(v[1], v[2], v[5], 0x0000ff)); // back
v.forEach(function (vv) { vv.multiplyScalar(1.3); });
var w = 0.05;
var c = 0xffffff;
sceneAdd(scene, createLine(v[0], v[6], w, c), "vertices");
sceneAdd(scene, createLine(v[1], v[7], w, c), "vertices");
sceneAdd(scene, createLine(v[2], v[4], w, c), "vertices");
sceneAdd(scene, createLine(v[3], v[5], w, c), "vertices");
showSceneObjects = function (category) {
scene.groupings.forEach(function (c) {
c.forEach(function (obj) { obj.visible = (category == undefined ? true : false); })
});
if (category != undefined)
scene.groupings.get(category).forEach(function (obj) { obj.visible = true; });
scene.doRender();
};
var l = 1.5; w = 0.05; c = 0xff5566;
sceneAdd(scene, createLine(new THREE.Vector3(-l, 0, 0), new THREE.Vector3(l, 0, 0), w, c), "faces");
sceneAdd(scene, createLine(new THREE.Vector3(0, -l, 0), new THREE.Vector3(0, l, 0), w, c), "faces");
sceneAdd(scene, createLine(new THREE.Vector3(0, 0, -l), new THREE.Vector3(0, 0, l), w, c), "faces");
var c = 0x5566ff;
for (var i = 0; i < e.length; i += 2) {
var v1 = mid(e[i], e[i + 1]).multiplyScalar(1.2);
var v2 = v1.clone().multiplyScalar(-1);
sceneAdd(scene, createLine(v1, v2, w, c), "edges");
}
}
</script>
<div class="rightBox" id="rboxSimple2">
</div>
<script>
function init() {
var d = document.getElementById("rboxSimple2");
var scene = getStandard3DView(d, getSideWidth(), getSideWidth());
var v = getVertices();
var e = getEdges();
for (var i = 0; i < e.length; i += 2) {
scene.add(createLine(e[i], e[i + 1], 0.02, 0xffffff));
}
scene.add(createPlane(v[0], v[2], v[4], 0xff0000));
scene.add(createPlane(v[1], v[3], v[5], 0xff0000));
scene.add(createPlane(v[0], v[3], v[5], 0x00ff00));
scene.add(createPlane(v[1], v[2], v[4], 0x00ff00));
scene.add(createPlane(v[4], v[5], v[3], 0x333333));
scene.add(createPlane(v[0], v[1], v[7], 0x333333));
scene.add(createPlane(mid(v[0], v[3]), mid(v[1], v[2]), mid(v[4], v[7]), 0x0000ff));
scene.add(createPlane(mid(v[0], v[1]), mid(v[2], v[3]), mid(v[4], v[5]), 0x0000ff));
scene.add(createPlane(mid(v[0], v[4]), mid(v[3], v[7]), mid(v[1], v[5]), 0x0000ff));
}
init();
</script>
<p>The cube has several
<em>automorphisms</em> - transformations that will map the cube onto itself. For instance, we can easily find several rotations
(between
<a href="" class="interactive" onmouseover="showSceneObjects('vertices')" onmouseout="showSceneObjects()">opposite vertices</a>: 4 (120 degrees), opposite
<a href="" class="interactive" onmouseover="showSceneObjects('edges')" onmouseout="showSceneObjects()">mid-edges</a>: 6 (180 degrees), and opposite
<a href="" class="interactive" onmouseover="showSceneObjects('faces')" onmouseout="showSceneObjects()">faces</a>: 3 (90 degrees): a total of 4*2+6*1+3*3 = 23 rotations.
</p>
<p> Including the identity transformation, and taking into account that we could also mirror each one of these transformations,
we arrive at
<b>48</b> automorphisms for the cube.
</p>
<p>
Besides the rotation symmetries above, we can also depict the reflection symmetries. Shown to the right are the 9 different such reflection operations, that will map the cube onto itself (although in a mirrored
version).
</p>
<p>These 48 transformations form a
<b>group</b>: a set of elements, together with a rule for combining any two elements such that the result is again an element
in the set. There must an identity element in the group, and every element must have an inverse element: i.e. an element
such that combining the element and its inverse results in the identity element.
</p>
<p>
In our case, combining any number of the 48 transformations will result in a transformation that is already present
in our set of transformations. Likewise, for all rotations and reflections, there exists an inverse transformation (for
180 degrees rotations, and for reflections, the transformations are their own inverses).
</p>
<p>These transformations are not independent: some transformations can be expressed by combining other transformations. Perhaps
it is possible to find a smaller subset of transformation that could be combined to form all the 48 automorphisms?
</p>
<p>
This is known as a set of
<b>generators</b>: a subset, S, of elements in the group G, which can be used to express all elements.
</p>
<div class="rightBox" id="rbox1">
</div>
<script>
function init() {
var d = document.getElementById("rbox1");
var scene = getStandard3DView(d, getSideWidth(), getSideWidth());
scene.getCamera().position.set(2.0, 0.4, 1.4 * 3.5);
scene.getControls().update();
var v = getVertices();
var e = getEdges();
for (var i = 0; i < e.length; i += 2) {
scene.add(createLine(e[i], e[i + 1], 0.02, 0xffffff));
}
scene.add(createPlane(v[0], v[2], v[4], 0x00ff00));
scene.add(createPlane(v[0], v[3], v[5], 0x0000ff));
scene.add(createPlane(mid(v[0], v[3]), mid(v[1], v[2]), mid(v[4], v[7]), 0xff0000));
}
init();
</script>
<p>
For the cube, it is possible to find a set of three reflections, which can be used to form all the 48 transformations. One such
set is shown to the right: here we have three reflection planes, which we could think of as operators - let us call them
R, G, and B after their colors. This set can be used to construct all other transformations.
</p>
<p>
Notice that the angle between the reflection planes (sometimes called <b>mirrors</b>) is: $$\angle(R,G) = 45^{\circ} $$ $$\angle(G,B) = 60^{\circ} $$ $$\angle(R,B)
= 90^{\circ} $$
</p>
<p>
<em>Now, combining two reflections results in a rotation of twice the angle between the reflection planes</em>. So applying e.g. GB
would be equal to a rotation of 120 degrees. And applying GB three times, e.g. GBGBGB, would not change the input.
</p>
<p>This means we can establish the following
<b>relations</b> between the generators:</p>
$$R^2 = B^2 = G^2 = (RG)^4 = (GB)^3 = (RB)^2 = I$$
<p>
Given a set of generators, how many different elements are there in our set? And can
we decide whether two compositions (say RGRG and RBG) are identical operations? This turns out to be a computationally hard problem, known as the
<a href="https://en.wikipedia.org/wiki/Word_problem_for_groups">word problem for groups</a>. But for some specific groups, this problem is computationally
tractable.
</p>
<div class="fullwidth">
<img src="img2.jpg" width="100%" />
</div>
<h2>The Todd-Coxeter Algorithm</h2>
<p>
Our example relations above form a special group, called a Coxeter group. That is a group where the generators have relations
of the form: \((ab)^{m_{ab}}\), as above: $$(RG)^4 = (GB)^3 = (RB)^2$$ The generators must also be their own inverse:
$$R^2 = B^2 = G^2$$ Since the generators are their own inverses, they can be associated with reflections.
</p>
<p>
For Coxeter groups, it is possible to identify all elements in the group, given the generators. The
<a href="https://en.wikipedia.org/wiki/Todd%E2%80%93Coxeter_algorithm">Todd-Coxeter Algorithm</a> provides a way to identify and count all elements generated by our generators.
(Quick digression: The Todd-Coxeter algorithm was one of the first non-numerical algorithm to be implemented on a digital computer - using an
<a href="https://www.cambridge.org/core/journals/mathematical-proceedings-of-the-cambridge-philosophical-society/article/coset-enumeration-on-digital-computers/047323FB9415ACF3466E627590ABB790">
EDSAC 1 in 1953</a>)
</p>
<p>Actually, the Todd-Coxeter algorithm does a bit more than counting the elements: it also allows for enumerating all <b>cosets</b> of G, for a given subgroup H. </p>
<p>What does this mean?</p>
<p>
A coset is the set resulting from multiplying all members in \(H\) by a group element \(g\) from \(G\). A (left) coset is written
\(gH\). The number of cosets is written \(|G:H|\). Lagrange's theorem states that \( [G:H]={|G| \over |H|} \). All the cosets
for a given subgroup form a new set, called a
<b>quotient set</b> (denoted G/H).
</p>
<p>The algorithm works by keeping track of several tables: a coset table (listing the generator actions on the different cosets),
a subgroup table (listing subgroup generator actions), and a table for each relation between the group generators. The
algorithm works by filling out rows in these tables. Once a row is closed, a (potentially) new piece of information is
known.
</p>
<p> Here is a demo (use the 'step' button to fill the table):
</p>
<div class="fullwidth" id="coxeterDemo">
<p>
Group:
<select class="fancy" onchange="updateToddCoxeter()" id="s1" style="width: 350px">
<option>rgrgrg,gbgbgb,rbrb (tetrahedron)</option>
<option selected="selected">rgrgrgrg,gbgbgb,rbrb (cube)</option>
<option>rgrgrg,gbgbgbgb,rbrb (octa)</option>
<option>rgrgrgrgrg,gbgbgb,rbrb (dodecahedron)</option>
<option>rgrgrg,gbgbgbgbgb,rbrb (icosahedron)</option>
</select>
Subgroup:
<select class="fancy" onchange="updateToddCoxeter()" id="s2" style="width: 150px">
<option>none</option>
<option>r,g</option>
<option>g,b</option>
<option selected="selected">r,b</option>
</select>
<a href="javascript:doStep()" class="interactive">Step</a>
<div id="output"></div>
<script>
var tcStep;
var doIteration;
var iter = 0;
function doStep() {
if (tcStep == undefined) {
tcStep = getTC();
doIteration = tcStep.initSolver();
iter = 0;
}
if (!doIteration()) {
var d = document.getElementById("output");
d.innerHTML = "<p>Number of cosets:" + tcStep.cosetTable.rows.length + "</p>" + tcStep.getTables();
tcStep = undefined; // reset
return;
}
var d = document.getElementById("output");
d.innerHTML = "<p><b>In progress (step " + (++iter) + ")</b><p>" + tcStep.getTables();
}
function getTC() {
var e = document.getElementById("s1");
var group = e.options[e.selectedIndex].value.split(" ")[0];
var e = document.getElementById("s2");
var subgroup = e.options[e.selectedIndex].value;
if (subgroup == "none") subgroup = undefined;
var tc = new ToddCoxeter(group, subgroup);
return tc;
}
function updateToddCoxeter() {
tcStep = undefined; // reset
var tc = getTC();
tc.solve();
var d = document.getElementById("output");
d.innerHTML = "<p>Number of cosets:" + tc.getCosetCounts() + "<p>" + tc.getTables();
}
updateToddCoxeter();
</script>
</div>
<p>Let us look at the various cosets you get when you use Todd-Coxeter on the symmetry groups for the regular polytopes, using different subsets of
the generators to specify a subgroup:</p>
<div class="fullwidth">
<table class="blueTable inlineCoxeter">
<thead>
<tr>
<th colspan=4 style="visibility: hidden; border: 0px"></th>
<th colspan=3>Subgroup cosets</th>
</tr>
</thead>
<thead>
<tr>
<th>Name</th>
<th>Diagram</th>
<th>Generator relations</th>
<th>Automorphisms</th>
<th>g,b</th>
<th>r,b</th>
<th>r,g</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tetrahedron</td>
<td>COX(3,3)</td>
<td>\((rg)^3\),\((gb)^3\);\((rb)^2\)</td>
<td>24</td>
<td>4</td>
<td>6</td>
<td>4</td>
</tr>
<tr>
<td>Cube</td>
<td>COX(4,3)</td>
<td>\((rg)^4\),\((gb)^3\),\((rb)^2\)</td>
<td>48</td>
<td>8</td>
<td>12</td>
<td>6</td>
</tr>
<tr>
<td>Octahedron</td>
<td>COX(3,4)</td>
<td>\((rg)^3\),\((gb)^4\),\((rb)^2\)</td>
<td>48</td>
<td>6</td>
<td>12</td>
<td>8</td>
</tr>
<tr>
<td>Dodecahedron</td>
<td>COX(5,3)</td>
<td>\((rg)^5\),\((gb)^3\),\((rb)^2\)</td>
<td>120</td>
<td>20</td>
<td>30</td>
<td>12</td>
</tr>
<tr>
<td>Icosahedron</td>
<td>COX(3,5)</td>
<td>\((rg)^3\),\((gb)^5\),\((rb)^2\)</td>
<td>120</td>
<td>12</td>
<td>30</td>
<td>20</td>
</tr>
<tr>
<th colspan=4 style="visibility: hidden; border: 0px"></th>
<th>Vertices</th>
<th>Edges</th>
<th>Faces</th>
</tr>
</tbody>
</table>
<table class="blueTable inlineCoxeter">
<thead>
<tr>
<th colspan=4 style="visibility: hidden; border: 0px"></th>
<th colspan=4>Subgroup cosets</th>
</tr>
</thead>
<thead>
<tr>
<th>Name</th>
<th>Diagrams</th>
<th>Generator relations</th>
<th>Automorphisms</th>
<th>g,b,a</th>
<th>r,b,a</th>
<th>r,g,a</th>
<th>r,g,b</th>
</tr>
</thead>
<tbody>
<tr>
<td>5-cell</td>
<td>COX(3,3,3)</td>
<td>\((rg)^3\),\((gb)^3\),\((ba)^3\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>120</td>
<td>5</td>
<td>10</td>
<td>10</td>
<td>5</td>
</tr>
<tr>
<td>8-cell</td>
<td>COX(4,3,3)</td>
<td>\((rg)^4\),\((gb)^3\),\((ba)^3\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>384</td>
<td>16</td>
<td>32</td>
<td>24</td>
<td>8</td>
</tr>
<tr>
<td>16-cell</td>
<td>COX(3,3,4)</td>
<td>\((rg)^3\),\((gb)^3\),\((ba)^4\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>384</td>
<td>8</td>
<td>24</td>
<td>32</td>
<td>16</td>
</tr>
<tr>
<td>24-cell</td>
<td>COX(3,4,3)</td>
<td>\((rg)^3\),\((gb)^4\),\((ba)^3\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>1152</td>
<td>24</td>
<td>96</td>
<td>96</td>
<td>24</td>
</tr>
<tr>
<td>120-cell</td>
<td>COX(5,3,3)</td>
<td>\((rg)^5\),\((gb)^3\),\((ba)^3\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>14400</td>
<td>600</td>
<td>1200</td>
<td>720</td>
<td>120</td>
</tr>
<tr>
<td>600-cell</td>
<td>COX(3,3,5)</td>
<td>\((rg)^3\),\((gb)^3\),\((ba)^5\),\((rb)^2\),\((ra)^2\),\((ga)^2\)</td>
<td>14400</td>
<td>120</td>
<td>720</td>
<td>1200</td>
<td>600</td>
</tr>
<tr>
<th colspan=4 style="visibility: hidden; border: 0px"></th>
<th>Vertices</th>
<th>Edges</th>
<th>Faces</th>
<th>Cells</th>
</tr>
</tbody>
</table>
</div>
<script>
var tables = document.getElementsByClassName("inlineCoxeter");
for (var t = 0, table; table = tables[t]; t++)
for (var i = 0, row; row = table.rows[i]; i++) {
for (var j = 0, c; c = row.cells[j]; j++) {
if (c.innerText && c.innerText.indexOf("COX") != -1) {
var reg = /COX\((.*)\)/g;
var match = reg.exec(c.innerText);
c.innerText = "";
insertCoxeter(c, match[1].split(","));
}
}
}
</script>
<p>An interesting structure emerges here: looking at the cosets for the subgroups generated by leaving out one of the generators,
<em>the number of cosets</em> matches the number of vertices, edges, or faces! It seems we can fully describe the geometric
structure by forming various quotient sets.</p>
<p>
Also notice, that the ordering matter here: the cube and octahedron have the same generators (just switch 'r' and 'b'), and
same symmetry group, but the number of faces and vertices are swapped. These shapes are said to be
<b>dual</b>. The Dodecahedron/Icosahedron, the 8-cell/16-cell, and 120-cell/600-cell all form dual pairs.
</p><p>
So what differentiates
a cube from an octahedron? The answer is, that it depends on how the initial vertex is placed. Notice the outer circle
on the first reflector, r, in the Coxeter diagram: this circle specifies that the initial vertex should be placed somewhere
<em>off</em> the reflection plane for r, but on the reflection planes for g and b. (This also means that the initial
vertex would be taken to itself when applying g and b).
</p>
<p>
Let us explore the quotient sets a bit more: how do we generate the geometry and how do we associate edges with vertices?
</p>
<div class="fullwidth">
<img src="img1.jpg" width="100%" />
</div>
<h2>Generating geometry from group structure</h2>
<p>
We will recreate the Euclidean geometry from the abstract Coxeter group description.
</p>
<p>
Given the generator relations, we know the angles between the reflector planes: If there is a relation on the form: \((RB)^{N}\),
the angle between the reflection planes R and B must be \( \pi / N \) - which again corresponds to a rotation of \( 2\pi / N \) degrees.
For the cube the angles between the reflection planes are 45, 60, and 90. The first
step is to create a set of reflection plane normal vectors with these angles between them.
This can be done iteratively, by starting with an arbitrary
unit vector, and adding vectors at corresponding angles, e.g.:
</p>
<p>
$$ \begin{pmatrix} & 1 \\ & 0 \\ & 0 \end{pmatrix}, \begin{pmatrix} & cos(\theta_{12}) \\ & N_1 \\ & 0 \end{pmatrix}, \begin{pmatrix}
& cos(\theta_{13}) \\ & \frac{cos(\theta_{23})-cos(\theta_{12})cos(\theta_{13}) }{N_1} \\ & N_2 \end{pmatrix} $$
</p>
<p>These vectors are the normals of the reflecting planes (The N's are normalization constants that can be trivially
calculated - all the normals must be unit length).</p>
<p>
We now have our reflection planes (the group generators) defined. Given a starting point, we can apply these and create the full geometry.
But how do we choose the starting point? As previously mentioned the cube and octahedron share the same generator relations
(they are dual). So why are they different? Looking at their coxeter diagram in the table above, this has to do with the
special outer circle. This outer circle has a special meaning: the initial starting point should be located on the two
other reflection planes (the blue and the green), but not on the red one.</p>
<p>
We can use
<a href="http://mathworld.wolfram.com/Gram-SchmidtOrthonormalization.html">Gram-Schmidt orthonormalization</a> to create a vector that is contained
in the blue and the green plane, but not in the
red plane. We do this by starting out with the three reflection plane normal vectors in the order blue, green, and red. After applying Gram-Schmidt
to this set of vectors, the last vector in the transformed set will be orthogonal to the blue and green reflection plane
normal vectors (and thus be located on the intersection of these two planes). The advantage of using Gram-Schmidt is that we can generalize this to four dimensions -
if we had used the cross product, that would not have been possible.
</p>
<p>The example below shows how this works for the dodecahedron. Like the cube, the dedocahedron can be generated by three generators,
with angles 36, 60, and 90 degrees between the reflecting planes.</p>
<div class="fullwidth" id="largeContainer">
<script>
function dumpTable(tc) {
var table = tc.cosetTable;
var genSymbols = tc.rels.generators;
var mapper = function (e) { return self.rels.generators[e]; };
var s = '<div id="table-scroll" style="vertical-align: top; height: 600px">';
s += "<table class='blueTable' style='height: 600px' id='mainTable'><thead><th></th><th>Element</th>";
for (var i = 0; i < table.genList.length; i++) {
s += "<th>" + genSymbols[table.genList[i]] + "</th>";
}
if (table.extraColumns) {
for (var i = 0; i < table.extraColumns.length; i++) {
s += "<th> " + table.extraColumnNames[i][0] + "</th>";
}
}
s += "</thead>";
for (var i = 0; i < table.rows.length; i++) {
s += "<tr><td>" + table.rowCosets[i] + "</td>";
var el = tc.getRepresentiveString(tc.getRepresentiveForCoset(i));
s += "<td>" + (el == "" ? "I" : el) + "</td>";
for (var j = 0; j < table.genList.length; j++) {
var o = table.rows[i][j];
s += "<td>" + (o == undefined ? "" : o) + "</td>";
}
if (table.extraColumns) {
for (var j = 0; j < table.extraColumns.length; j++) {
s += "<td><a class='interactive' onmouseover='selectRow(" + j + "," + i + ")' onmouseout='selectRow(" + j + ")'>" + table.extraColumnNames[j][1] + table.extraColumns[j][i] + "</a></td>";
}
}
s += "</tr>";
}
s += "</table></div>";
return s;
};
var freeGroup = getCoxeterGroup(5, 3, 2);
// Find vertices
function getVertixMatrices(vertexOperators, reflectionMatrices) {
var ms = new Array(vertexOperators.length);
for (var i = 0; i < vertexOperators.length; i++) {
var operatorList = vertexOperators[i];
var m = new THREE.Matrix3();
for (var j = 0; j < operatorList.length; j++) {
m.premultiply(reflectionMatrices[operatorList[j]]);
}
ms[i] = m;
}
return ms;
}
var container = document.createElement('span');
document.getElementById("largeContainer").appendChild(container);
container.innerHTML += dumpTable(freeGroup);
</script>
<script>
var setInitialVertex;
values = {};
var cayley;
var structure = freeGroup.getStructure();
function createOrtho(v1) {
var v2;
if (v1.x == 0 && v1.y == 0) {
v2 = new THREE.Vector3(1, 0, 0);
} else {
v2 = new THREE.Vector3(v1.y, -v1.x, 0); v2.normalize();
}
return [v2, new THREE.Vector3().crossVectors(v1, v2).normalize()];
}
function init() {
var container = document.createElement('div');
container.style.display = "inline";
document.getElementById("largeContainer").appendChild(container);
var scene = getStandard3DView(container, 600, 600);
scene.getCamera().position.set(2.0, 1.4, 1.4 * 3.5);
scene.getControls().update();
var nG;
var nB;
var nR;
var a12 = Math.PI / freeGroup.powers[0];
var a23 = Math.PI / freeGroup.powers[1];
var a13 = Math.PI / freeGroup.powers[2];
nR = new THREE.Vector3(1, 0, 0);
nG = new THREE.Vector3(Math.cos(a12), Math.sqrt(1 - Math.cos(a12) * Math.cos(a12)), 0);
var nb1 = Math.cos(a13);
var nb2 = (Math.cos(a23) - nG.x * nb1) / nG.y;
var nb3 = Math.sqrt(1 - nb1 * nb1 - nb2 * nb2);
nB = new THREE.Vector3(nb1, nb2, nb3);
var O = new THREE.Vector3(0, 0, 0);
var frame = [];
var orthoFrame = createOrtho(nR);
var obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0xff0000);
scene.add(obj); frame.push(obj);
scene.add(obj); frame.push(obj);
orthoFrame = createOrtho(nG);
obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0x00ff00);
scene.add(obj); frame.push(obj);
orthoFrame = createOrtho(nB);
obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0x0000ff);
scene.add(obj); frame.push(obj);
var nBp = gramSchmidt([nG, nR, nB])[2];
var nRp = gramSchmidt([nB, nG, nR])[2];
var nGp = gramSchmidt([nR, nB, nG])[2];
if (nRp.dot(nBp) < 0) nRp.multiplyScalar(-1);
if (nGp.dot(nBp) < 0) nGp.multiplyScalar(-1);
var w = 0.01;
var arrowWidth = 0.03;
var arrowLength = 0.1;
obj = createLine(O, nGp.clone().multiplyScalar(2.0), w, 0x00ff00, arrowWidth, arrowLength);
scene.add(obj); frame.push(obj);
obj = createLine(O, nBp.clone().multiplyScalar(2.0), w, 0x0000ff, arrowWidth, arrowLength);
scene.add(obj); frame.push(obj);
obj = createLine(O, nRp.clone().multiplyScalar(2.0), w, 0xff0000, arrowWidth, arrowLength);
scene.add(obj); frame.push(obj);
// Get vertices
var reflectionMatrices = [];
reflectionMatrices.push(getReflectionMatrix(nR.x, nR.y, nR.z));
reflectionMatrices.push(getReflectionMatrix(nG.x, nG.y, nG.z));
reflectionMatrices.push(getReflectionMatrix(nB.x, nB.y, nB.z));
var ms = getVertixMatrices(structure.vertexOperators, reflectionMatrices);
var spheres = [];
var cayley = [];
cayley.clear = function () {
var a;
while (a = cayley.pop()) {
scene.remove(a);
a.geometry.dispose();
}
}
showCayley = function (generators) {
cayley.clear();
if (generators == undefined) {
frame.forEach(function (e) { e.visible = true; });
scene.doRender();
return;
}
frame.forEach(function (e) { e.visible = false; });
var posX = spheres[0].position.clone();
var m = THREE.matrix3;
var prev;
var colors = [0xff0000, 0x00ff00, 0x0000ff];
for (var i = -1; i < generators.length; i++) {
if (i != -1) {
posX.applyMatrix3(reflectionMatrices[generators[i]]);
}
if (i == generators.length - 1) {
var geometry = new THREE.SphereGeometry(0.05, 32, 32);
var material = new THREE.MeshStandardMaterial({ color: 0x000000 });
var sphere = new THREE.Mesh(geometry, material);
sphere.position.copy(posX);
scene.add(sphere);
cayley.push(sphere);
}
if (prev != undefined) {
var arrowWidth = 0.06;
var arrowLength = 0.2;
var s = createLine(prev, posX, 0.022, colors[generators[i]], arrowWidth, arrowLength);
if (s != undefined) {
scene.add(s);
cayley.push(s);
}
}
prev = posX.clone();
scene.doRender();
}
}
showEdge = function (edge) {
cayley.clear();
if (edge == undefined) {
frame.forEach(function (e) { e.visible = true; });
scene.doRender();
return;
}
frame.forEach(function (e) { e.visible = false; });
var arrowWidth = 0.06;
var arrowLength = 0.2;
var s = createLine(spheres[edge[0]].position, spheres[edge[1]].position, 0.022, 0x000000, arrowWidth, arrowLength);
cayley.push(s);
scene.add(s);
s = createLine(spheres[edge[1]].position, spheres[edge[0]].position, 0.022, 0x000000, arrowWidth, arrowLength);
cayley.push(s);
scene.add(s);
scene.doRender();
}
showFace = function (face, edgeList) {
cayley.clear();
if (face == undefined) {
frame.forEach(function (e) { e.visible = true; });
scene.doRender();
return;
}
frame.forEach(function (e) { e.visible = false; });
var arrowWidth = 0.06;
var arrowLength = 0.2;
for (var i = 0; i < face.length; i++) {
var edge = edgeList[face[i]];
var s = createLine(spheres[edge[0]].position, spheres[edge[1]].position, 0.022, 0x000000);
cayley.push(s);
scene.add(s);
s = createLine(spheres[edge[1]].position, spheres[edge[0]].position, 0.022, 0x000000);
cayley.push(s);
scene.add(s);
}
scene.doRender();
}
setInitialVertex = function (v1, v2, v3) {
var pos = new THREE.Vector3(0, 0, 0);
pos.addScaledVector(nRp, v1);
pos.addScaledVector(nGp, v2);
pos.addScaledVector(nBp, v3);
for (var i = 0; i < spheres.length; i++) {
scene.remove(spheres[i]);
spheres[i].geometry.dispose();
}
spheres = [];
for (var i = 0; i < ms.length; i++) {
var geometry = new THREE.SphereGeometry(0.034, 32, 32);
var material = new THREE.MeshStandardMaterial({ color: (i != 0 ? 0xffffff : 0x000000) });
var sphere = new THREE.Mesh(geometry, material);
sphere.position.copy(pos.clone().applyMatrix3(ms[i]));
scene.add(sphere);
spheres.push(sphere);
}
for (var i = 0; i < structure.edgeList.length; i++) {
var v1 = structure.edgeList[i][0];
var v2 = structure.edgeList[i][1];
var s = createLine(spheres[v1].position, spheres[v2].position, 0.02, 0xffffff);
if (s != undefined) {
scene.add(s);
spheres.push(s);
}
}
scene.doRender();
}
setInitialVertex(1, 0, 0);
}
init();
function selectRow(col, r) {
var table = document.getElementById("mainTable");
var ct = freeGroup.cosetTable;
var selected = (col == undefined ? -1 : ct.extraColumns[col][r]);
for (var i = 1, row; row = table.rows[i]; i++) {
var val = ct.extraColumns[col][i - 1];
row.className = (val == selected ? "highlight" : "");
}
if (col == 0) {
showCayley(ct.reps[r]);
} else
if (col == 1) {
var edge = ct.extraColumns[col][r];
showEdge(structure.edgeList[edge]);
} else
if (col == 2) {
var face = ct.extraColumns[col][r];
showFace(structure.faceList[face], structure.edgeList);
}
}
</script>
</div>
<p>
The table can be used to explore how the different quotient sets ties the vertices, edges, and faces together. Try hovering an entry.
</p>
<p>
For instance, see how vertex
<a class='interactive' onmouseover='selectRow(0,0)' onmouseout='selectRow(0)'>V0</a> connects to three edges (E0,E1,E3) and three faces (F0,F1,F2). Likewise, edge
<a class='interactive' onmouseover='selectRow(1,0)' onmouseout='selectRow(0)'>E0</a> connects two vertices (V0,V1) and two faces (F0, F1). The face
<a class='interactive' onmouseover='selectRow(2,0)' onmouseout='selectRow(0)'>F0</a> connects five vertices (V0,V1,V2,V3,V5) and five edges (E0,E1,E2,E4,E6)
</p>
<p>Also notice the volume enclosed by the three arrows. This is the
<b>fundamental domain</b>, which will we return to in the next section.</p>
<div class="fullwidth">
<img src="img4.jpg" width="100%" />
</div>
<h2>Ray tracing reflection groups</h2>
<p>I have long been a fan of ray marching, and
<a href="http://blog.hvidtfeldts.net/index.php/2011/06/distance-estimated-3d-fractals-part-i/">distance estimation techniques</a>.
</p>
<p>
The previous section showed how to construct geometry by explicitly calculating positions for vertices, edges, and faces, and then displaying
the structures by rasterizing polygons (using WebGL).
</p>
<p>
But it is possible to construct very efficient distance estimators for the reflection group polytopes - including the four-dimensional
ones. Utilizing modern GPUs, this makes it possible to ray trace high-quality images in real-time.
</p>
<p>
This technique was originally described by Knighty in this
<a href="http://www.fractalforums.com/fragmentarium/solids-many-many-solids/">Fractal Forums thread</a> from 2012.
</p>
<p>The basic idea is a clever trick: instead of trying to calculate the positions of all vertices and edges, we will
first transform (using the group reflections) all points in space into the same 'fundamental' region or domain.
The basic building block will be a
<b>fold</b>: a simple conditional reflection - if we are on the wrong side of a reflection plane, we will do the reflection
- otherwise not. Once our paths of folds ends in the fundamental domain, we can quickly test whether we are inside a vertex, edge, or plane (at
least after assigning a width to these objects). We can also calculate the distance to the nearest part of the structure
this way.
</p>
<p>
Being able to calculate the distance to the nearest part of a structure is very powerful. Given this
<b>distance estimator</b>, we can render our object using
<b>ray marching</b>: we can take steps along a ray from the camera, and stop once we are sufficiently close to the object.
The distance estimator tells us how large steps we are allowed to march. And, since we now know how to determine how an
arbitrary ray intersects our structure, we can ray trace it, including shadows and reflections. I previously described the technique
<a href="http://blog.hvidtfeldts.net/index.php/2011/08/distance-estimated-3d-fractals-iii-folding-space/">here</a> for a recursive tetrahedron.
</p>
<div class="fullwidth" id="distanceContainer"></div>
<script>
var setDistancePoint;
var structure = freeGroup.getStructure();
var domainCenter;
function init() {
var container = document.createElement('div');
container.style.display = "inline";
document.getElementById("distanceContainer").appendChild(container);
var scene = getStandard3DView(container, 600, 600);
var nG;
var nB;
var nR;
var a12 = Math.PI / freeGroup.powers[0];
var a23 = Math.PI / freeGroup.powers[1];
var a13 = Math.PI / freeGroup.powers[2];
nR = new THREE.Vector3(1, 0, 0);
nG = new THREE.Vector3(Math.cos(a12), Math.sqrt(1 - Math.cos(a12) * Math.cos(a12)), 0);
var nb1 = Math.cos(a13);
var nb2 = (Math.cos(a23) - nG.x * nb1) / nG.y;
var nb3 = Math.sqrt(1 - nb1 * nb1 - nb2 * nb2);
nB = new THREE.Vector3(nb1, nb2, nb3);
var O = new THREE.Vector3(0, 0, 0);
var frame = [];
var orthoFrame = createOrtho(nR);
var obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0xff0000);
scene.add(obj); frame.push(obj);
scene.add(obj); frame.push(obj);
orthoFrame = createOrtho(nG);
obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0x00ff00);
scene.add(obj); frame.push(obj);
orthoFrame = createOrtho(nB);
obj = createOrigoPlane(orthoFrame[0], orthoFrame[1], 0x0000ff);
scene.add(obj); frame.push(obj);
var nBp = gramSchmidt([nG, nR, nB])[2];
var nRp = gramSchmidt([nB, nG, nR])[2];
var nGp = gramSchmidt([nR, nB, nG])[2];
if (nRp.dot(nBp) < 0) nRp.multiplyScalar(-1);
if (nGp.dot(nBp) < 0) nGp.multiplyScalar(-1);
domainCenter = new THREE.Vector3((nBp.x + nRp.x + nGp.x) / 3.0, (nBp.y + nRp.y + nGp.y) / 3.0, (nBp.z + nRp.z + nGp.z) / 3.0);
nR.multiplyScalar(-1.0);