-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdodecahedron.html
211 lines (178 loc) · 5.36 KB
/
dodecahedron.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MathBox - Empty Example.</title>
<!--
This example is good for starting from.
-->
<script type="text/javascript" charset="utf-8" src="../mathbox/vendor/domready.js"></script>
<script type="text/javascript" charset="utf-8" src="../mathbox/build/MathBox-bundle.js"></script>
<script type="text/javascript" charset="utf-8" src="dodecahedrons.js"></script>
<script type="text/javascript">
DomReady.ready(function () {
if (location.href.match(/^file:/)) {
document.getElementById('info').style.opacity = 1;
document.getElementById('info').innerHTML = "Sorry. This example does not work when accessed using file://. Please use an http:// host and try again.";
}
});
</script>
<script type="text/javascript">
function mathboxSetup() {
// Viewport camera/setup
mathbox
// Cartesian viewport
.viewport({
type: 'cartesian',
range: [[-3, 3], [-3, 3], [-3, 3]],
scale: [1, 1, 1],
})
.camera({
orbit: 3.5,
phi: τ/4,
theta: 0,
})
.transition(300)
}
var mathboxScript = [
// Steps go here
['add', 'vector', {
n: 30,
data: dodecahedron(),
arrow: false,
// ...
}, {
delay: 500,
duration: 300,
}],
];
</script>
<script type="text/javascript">
/**
* Bootstrap
*/
DomReady.ready(function() {
ThreeBox.preload([
'../mathbox/build/MathBox.glsl.html',
], function () {
// MathBox boilerplate
var mathbox = window.mathbox = mathBox({
cameraControls: true,
cursor: true,
controlClass: ThreeBox.OrbitControls,
elementResize: true,
fullscreen: true,
screenshot: true,
stats: false,
scale: 1,
}).start();
// Set up director
var script = window.mathboxScript;
var director = window.director = new MathBox.Director(mathbox, script);
// Arrow controls
// Controls for stand-alone
window.addEventListener('touchstart', function (e) {
director.forward();
document.getElementById('info').style.opacity = '0';
});
window.addEventListener('keydown', function (e) {
if (e.keyCode == 38 || e.keyCode == 37) director.back();
else if (e.keyCode == 40 || e.keyCode == 39) director.forward();
else {
return;
}
document.getElementById('info').style.opacity = '0';
});
window.mathboxSetup(mathbox);
// Setting up the base
mathbox.grid();
mathbox.axis({
id: 'x-axis',
axis: 0,
color: 0xff0000,
ticks: 5,
lineWidth: 2,
size: .05,
labels: true,
});
mathbox.axis({
id: 'y-axis',
axis: 1,
color: 0x00ff00,
ticks: 5,
lineWidth: 2,
size: .05,
labels: true,
zero: false,
});
mathbox.axis({
id: 'z-axis',
axis: 2,
color: 0x00ff00,
ticks: 5,
lineWidth: 2,
size: .05,
zero: false,
labels: true,
});
// set up the edges of each shape
var dodecahedron_edges = dodecahedron();
var dodecahedron_translation = [0, 0, translation_factor()];
var dodecahedron_rotation = [(Math.PI - Math.atan(2)), 0, 0];
var schlegel_edges = schlegel();
var schlegel_rotation = [0,0, Math.PI / 180 * 72];
var schlegel_translation = [0,0, 0];
// set up the dodecahedron as a bunch of individual vectors.
function setup_figure(edges, figure_name, vector_rotations, vector_translations){
for (var i = 0; i < edges.length; i += 2) {
mathbox.vector({
n: 1,
id: figure_name + String(i),
arrow: false,
data: [edges[i], edges[i + 1]],
lineWidth: 3,
mathRotation: vector_rotations,
mathPosition: vector_translations
// worldRotation: vector_rotations,
// worldPosition: vector_translations
});
}
}
// setup_figure(dodecahedron_edges, "dodecahedron", dodecahedron_rotation, dodecahedron_translation);
// setup_figure(schlegel_edges, "schlegel", schlegel_rotation, schlegel_translation);
// The mapping from old vectors to new:
var theta = Math.PI / 180 * 72
var base_rotation = Math.PI / 2;
var inner_offset = true
function mapping(){
}
// Dodecahedron
mathbox.vector({
id: "dodecahedron",
n: 30,
arrow: false,
data: dodecahedron(),
// This rotation should be exact - theoretically I can make use of this with a rotation
// matrix for the original vectors.
mathRotation: [(Math.PI - Math.atan(2)), 0, 0],
mathPosition: [0, 0, translation_factor()]
// worldRotation: [(Math.PI - Math.atan(2)), 0, 0],
// worldPosition: [0, 0, translation_factor()/2]
})
// Schlegel diagram
// mathbox.vector({
// id: "schlegel",
// n: 30,
// arrow: false,
// line: false,
// data: schlegel(),
// })
});
});
</script>
<link href="../mathbox/examples/base.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<div id="info"></div>
</body>
</html>