-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS2_minus_S1.html
171 lines (146 loc) · 5.05 KB
/
S2_minus_S1.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>S2\S1</title>
<style type="text/css" media="screen">
@import url(algtop_demo.css);
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {inlineMath: [["$","$"]]}
});
</script>
<script src="https://preview.babylonjs.com/babylon.js"></script>
<script src="algtop.js"></script>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
canvas {
width: 100%;
height: 600px;
touch-action: none;
}
</style>
</head>
<body>
<div style="text-align:center">
<div id="control_div" style="position:absolute; left:50px; top:50px;">
<div class="control" style="width: 150px;" id="index" onclick="location='index.php'">Index</div>
<div class="control" style="width: 150px;" id="S2_minus_1">$S^2\setminus\text{point}$</div>
<div class="control" style="width: 150px;" id="S2_minus_S0">$S^2\setminus S^0$</div>
<div class="control_selected" style="width: 150px;" id="S2_minus_S1">$S^2\setminus S^1$</div>
</div>
<canvas id="main_canvas"></canvas>
<div id="slidecontainer" style="width: 800px; margin: 0 auto;">
<input type="range" min="0" max="100" value="0" class="slider" id="stage_slider">
</div>
<br/><br/>
<div id="text" style="width: 800px; margin: 0 auto; text-align:left">
This illustrates the fact that $S^2\setminus S^1$ is homotopy equivalent
to $S^0$. In more detail: the full sphere is $S^2$, and $S^1$ is
the equator, marked in green. The space $S^0$ just consists of
the north and south poles, marked in red. After removing the
equator we can peel the remaining space $S^2\setminus S^1$ back to
the poles, so $S^2\setminus S^1$ is homotopy equivalent to $S^0$.
</div>
</div>
<script>
var demo = {};
demo.init = function() {
var me = this;
d = document.getElementById('S2_minus_1');
d.onclick = function() { window.location = 'S2_minus_1.html'; }
d = document.getElementById('S2_minus_S0');
d.onclick = function() { window.location = 'S2_minus_S0.html'; }
this.slider = document.getElementById("stage_slider");
this.canvas = document.getElementById("main_canvas");
this.engine =
new BABYLON.Engine(this.canvas, true, { preserveDrawingBuffer: true, stencil: true });
this.scene = algtop.basic_scene(this.engine,this.canvas);
this.sphere0 = Object.create(algtop.sphere);
this.sphere0.n = 256;
this.sphere0.make_mesh(this.scene);
var mat = new BABYLON.StandardMaterial("mat", this.scene);
mat.alpha = 0.4;
mat.backFaceCulling = false;
mat.diffuseColor = new BABYLON.Color3(0.5,0.5,0.5);
this.sphere0.mesh.material = mat;
this.r = 3;
this.s = 0;
this.disc0 = Object.create(algtop.surface);
this.disc0.normal = function(t,u) {
var a = 2 * Math.PI * t;
var b = 0.5 * Math.PI * (1 - 0.98 * u * (1 - me.s));
var x = Math.cos(a) * Math.cos(b);
var y = Math.sin(a) * Math.cos(b);
var z = Math.sin(b);
return [y,z,x];
}
this.disc0.embedding = function(t,u) {
var x = this.normal(t,u);
return [me.r * x[0],me.r * x[1],me.r * x[2]];
}
this.disc0.make_mesh(this.scene);
this.disc1 = Object.create(algtop.surface);
this.disc1.normal = function(t,u) {
var a = 2 * Math.PI * t;
var b = -0.5 * Math.PI * (1 - 0.98 * u * (1 - me.s));
var x = Math.cos(a) * Math.cos(b);
var y = Math.sin(a) * Math.cos(b);
var z = Math.sin(b);
return [y,z,x];
}
this.disc1.embedding = function(t,u) {
var x = this.normal(t,u);
return [me.r * x[0],me.r * x[1],me.r * x[2]];
}
this.disc1.make_mesh(this.scene);
this.ring = {};
this.ring.positions = [];
this.ring.n = 96;
for (i = 0; i <= this.ring.n; i++) {
this.ring.positions.push(
algtop.bab.vect([this.r * Math.sin(2 * Math.PI * i/this.ring.n),
0,
this.r * Math.cos(2 * Math.PI * i/this.ring.n)
]));
}
this.ring.cols =
Array(this.ring.positions.length).fill(new BABYLON.Color4(0,1,0,1));
this.ring.mesh = BABYLON.MeshBuilder.CreateLines('ring',
{points : this.ring.positions, colors : this.ring.cols, alpha : 1, updatable : true}, this.scene);
this.poles = [
algtop.bab.point([0, this.r,0],[1,0,0],0.1,this.scene),
algtop.bab.point([0,-this.r,0],[1,0,0],0.1,this.scene),
];
this.engine.runRenderLoop(function () {
if (me.scene) {
me.scene.render();
}
});
window.addEventListener("resize", function () {
me.engine.resize();
});
this.slider.oninput = function() {
me.set_stage(this.value);
}
}
demo.set_stage = function(i) {
var j;
this.s = parseInt(i) * 0.01;
this.disc0.update_mesh();
this.disc1.update_mesh();
}
demo.init();
</script>
</body>
</html>