-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
283 lines (278 loc) · 12.7 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Macchina Convessa PGL</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div id="app">
<svg class="graph" v-bind="graphPos" transform="scale(1,-1)">
<!-- grid -->
<g v-for="n in netSize">
<circle v-for="m in netSize" v-bind:cx="m-netOrigin" v-bind:cy="n-netOrigin" v-bind:r="integerPointSize" class="intpoint">
<animate v-if="isInside(m-netOrigin,n-netOrigin)" attributeType="XML" repeatCount="indefinite" attributeName="fill" values="#f00;#f00;#fff" dur="0.7s" />
</circle>
</g>
<!-- the ellipses -->
<g v-if="showEllipses">
<ellipse v-bind="inertiaA" class="ainertia" v-bind:stroke-width="edgeWidth" />
<line v-bind:x1="inertiaA.cx-2*inertiaA.rx" v-bind:y1="inertiaA.cy" v-bind:x2="inertiaA.cx+2*inertiaA.rx" v-bind:y2="inertiaA.cy" v-bind:transform="inertiaA.transform" class="ainertia" v-bind:stroke-width="edgeWidth/2" />
<line v-bind:x1="inertiaA.cx" v-bind:y1="inertiaA.cy-2*inertiaA.ry" v-bind:x2="inertiaA.cx" v-bind:y2="inertiaA.cy+2*inertiaA.ry" v-bind:transform="inertiaA.transform" class="ainertia" v-bind:stroke-width="edgeWidth/2" />
<ellipse v-bind="inertiaD" class="dinertia" v-bind:stroke-width="edgeWidth" />
<line v-bind:x1="inertiaD.cx-2*inertiaD.rx" v-bind:y1="inertiaD.cy" v-bind:x2="inertiaD.cx+2*inertiaD.rx" v-bind:y2="inertiaD.cy" v-bind:transform="inertiaD.transform" class="dinertia" v-bind:stroke-width="edgeWidth/2" />
<line v-bind:x1="inertiaD.cx" v-bind:y1="inertiaD.cy-2*inertiaD.ry" v-bind:x2="inertiaD.cx" v-bind:y2="inertiaD.cy+2*inertiaD.ry" v-bind:transform="inertiaD.transform" class="dinertia" v-bind:stroke-width="edgeWidth/2" />
</g>
<!-- edges -->
<line v-for="(i,l) in dLines" v-bind="l" @mousedown.prevent="addPoint($event,i,false)" class="dualEdge" v-bind:stroke-width="edgeWidth"/>
<line v-for="(i,l) in aLines" v-bind="l" @mousedown.prevent="addPoint($event,i,true)" class="edge" v-bind:stroke-width="edgeWidth"/>
<!-- vertices -->
<circle v-for="(i,p) in aVertices" v-bind="p" @mousedown.prevent="startMove($event,i,true)" @touchstart.prevent="startMove($event,i,true)" v-bind:r="vertexSize" class="pointer" v-bind:class="{ selected: p.selected}" />
<circle v-for="(i,p) in dVertices" v-bind="p" @mousedown.prevent="startMove($event,i,false)" @touchstart.prevent="startMove($event,i,false)" v-bind:r="vertexSize" class="pointer" v-bind:class="{ selected: p.selected}" />
<!-- centroids -->
<circle v-bind="centroidD" v-bind:r="vertexSize" v-bind:stroke-width="vertexSize/3" class="dcentroid"></circle>
<circle v-bind="centroidA" v-bind:r="vertexSize" v-bind:stroke-width="vertexSize/3" class="acentroid"></circle>
<circle cx="0" cy="0" v-bind:r="vertexSize/2" v-bind:stroke-width="vertexSize/3" class="origin"></circle>
</svg>
<!-- ============================================ -->
<div class="settings" v-cloak>
Example:
<select v-model="selectedExample" @change="setExample">
<option v-for="e in examples" v-bind:value="e">
{{ e.title }}
</option>
</select>
<span v-if="!isSymetric"><button @click="makeSymetric()">Make it symetric</button></span>
<a href="https://ktzanev.github.io/convex-pgl?a={{aString}}" class="pgllink">ConvexPGL ⮵</a>
<br>
<hr>
<!-- ================== A ===================== -->
<input type="text" v-model="aString" class="string field">
<span class="round colorA">Volume A: {{volumeA.toFixed(3)}}</span>
<button @click="centroidAtZero(true)" class="round colorA">g(A)→0</button>
<button @click="santaloAtZero(true)" class="round colorA">s(A)~>0</button>
<div class="controlblock">
Transform :
<button @click="linearTransform(true,[1,0,-1,1])" class="round colorA">←</button>
<button @click="linearTransform(true,[1,0,1,1])" class="round colorA">→</button>
<button @click="linearTransform(true,[1,1,0,1])" class="round colorA">↑</button>
<button @click="linearTransform(true,[1,-1,0,1])" class="round colorA">↓</button>
</div>
<div class="controlblock">
In isotropic position:
<select v-model="isotropicPositionASetter">
<option v-bind:value="false">no</option>
<option value="Ĩ=1">Ĩ=1</option>
<option value="I=1">I=1</option>
<option value="VA=VD">VA=VD</option>
<option value="VA=1">VA=1</option>
<option value="keep VA">keep VA</option>
</select>
</div>
<br>
<div class="controlblock colorA">
Show
<select v-model="showEllipses">
<option v-bind:value="false">no ellipse</option>
<option value="standard">standard</option>
<option value="normalized">normalized</option>
</select>
<span v-if="showEllipses">
<select v-model="ellipseTypeA">
<option value="binet">Binet</option>
<option value="legendre">Legendre</option>
<option value="lyz">Lutwak-Yang-Zhang</option>
</select>
centered at
<select v-model="centerEllipses">
<option value="centroid">centroid</option>
<option value="zero">zero</option>
</select>
</span>
</div>
<hr>
<!-- ============= MIDDLE ===================== -->
<div v-if="showEllipses=='normalized' && ellipseTypeA != ellipseTypeD" class="conjecture">
Conjecture : The normalized Binet <b>is not inside</b> the normalized Legendre of the dual (at critical ? isotropic ? position).
</div>
<hr>
<button @click="startCentroidPingPong()" v-show="cID === null">start Centroid Ping-Pong</button>
<button @click="stopCentroidPingPong()" v-show="cID !== null" class="stoppingpong">stop Centroid Ping-Pong</button>
<button @click="startSantaloPingPong()" v-show="sID === null">start Santaló Ping-Pong</button>
<button @click="stopSantaloPingPong()" v-show="sID !== null" class="stoppingpong">stop Santaló Ping-Pong</button>
<div class="round colorAD">VA*VD={{volumeAD.toFixed(4)}}</div>
<div class="hessian">
-12 x (<span class="colorD">{{volumeD.toFixed(4)}}</span>)
<table class="colorA">
<tr>
<td>{{z2A[0].toFixed(4)}}</td>
<td>{{z2A[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{z2A[1].toFixed(4)}}</td>
<td>{{z2A[3].toFixed(4)}}</td>
</tr>
</table>
(Id - 16/<span class="colorAD">{{volumeAD.toFixed(4)}}</span>
<table class="colorD">
<tr>
<td>{{z2D[0].toFixed(4)}}</td>
<td>{{z2D[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{z2D[1].toFixed(4)}}</td>
<td>{{z2D[3].toFixed(4)}}</td>
</tr>
</table>
<table class="colorA">
<tr>
<td>{{z2A[0].toFixed(4)}}</td>
<td>{{z2A[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{z2A[1].toFixed(4)}}</td>
<td>{{z2A[3].toFixed(4)}}</td>
</tr>
</table>
)
</div>
<div class="hessian">(<span class="colorD">{{(-12*volumeD).toFixed(4)}}</span>)
<table class="colorA">
<tr>
<td>{{z2A[0].toFixed(4)}}</td>
<td>{{z2A[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{z2A[1].toFixed(4)}}</td>
<td>{{z2A[3].toFixed(4)}}</td>
</tr>
</table>
<table class="colorADb">
<tr>
<td>{{factorDA[0].toFixed(4)}}</td>
<td>{{factorDA[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{factorDA[1].toFixed(4)}}</td>
<td>{{factorDA[3].toFixed(4)}}</td>
</tr>
</table>
=
<table class="colorADc">
<tr>
<td>{{hessianDA[0].toFixed(4)}}</td>
<td>{{hessianDA[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{hessianDA[1].toFixed(4)}}</td>
<td>{{hessianDA[3].toFixed(4)}}</td>
</tr>
</table>
</div>
<br>
<div class="hessian">tr(
<table class="colorADb">
<tr>
<td>{{factorDA[0].toFixed(4)}}</td>
<td>{{factorDA[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{factorDA[1].toFixed(4)}}</td>
<td>{{factorDA[3].toFixed(4)}}</td>
</tr>
</table>
)= {{(factorDA[0]+factorDA[3]).toFixed(4)}},
</div>
<div class="hessian">
tr(
<table class="colorADc">
<tr>
<td>{{hessianDA[0].toFixed(4)}}</td>
<td>{{hessianDA[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{hessianDA[1].toFixed(4)}}</td>
<td>{{hessianDA[3].toFixed(4)}}</td>
</tr>
</table>
) = {{(hessianDA[0]+hessianDA[3]).toFixed(4)}},
det(
<table class="colorADc">
<tr>
<td>{{hessianDA[0].toFixed(4)}}</td>
<td>{{hessianDA[2].toFixed(4)}}</td>
</tr>
<tr>
<td>{{hessianDA[1].toFixed(4)}}</td>
<td>{{hessianDA[3].toFixed(4)}}</td>
</tr>
</table>
) = {{(hessianDA[0]*hessianDA[3] - hessianDA[1]*hessianDA[2]).toFixed(4)}}
</div>
<hr>
<!-- ================== D ===================== -->
<input type="text" v-model="dString" class="string field">
<span class="round colorD">Volume D: {{volumeD.toFixed(3)}}</span>
<button @click="centroidAtZero(false)" class="round colorD">g(D)→0</button>
<button @click="santaloAtZero(false)" class="round colorD">s(D)~>0</button>
<div class="controlblock">
Transform :
<button @click="linearTransform(false,[1,0,-1,1])" class="round colorD">←</button>
<button @click="linearTransform(false,[1,0,1,1])" class="round colorD">→</button>
<button @click="linearTransform(false,[1,1,0,1])" class="round colorD">↑</button>
<button @click="linearTransform(false,[1,-1,0,1])" class="round colorD">↓</button>
</div>
<br>
<div class="controlblock colorD">
Show
<select v-model="showEllipses">
<option v-bind:value="false">no ellipse</option>
<option value="standard">standard</option>
<option value="normalized">normalized</option>
</select>
<span v-if="showEllipses">
<select v-model="ellipseTypeD">
<option value="binet">Binet</option>
<option value="legendre">Legendre</option>
<option value="lyz">Lutwak-Yang-Zhang</option>
</select>
centered at
<select v-model="centerEllipses">
<option value="centroid">centroid</option>
<option value="zero">zero</option>
</select>
</span>
</div>
<hr>
<!-- ============= CONTROLS ===================== -->
<div class="controls">
<h2>Settings</h2>
Zoom: <input type="range" v-model="graphSize" min="5" max="21" step="2"><br>
Vertex size: <input type="range" min="0" max="0.5" step="0.01" v-model="vertexSize"><br>
Edge width: <input type="range" min="0" max="0.5" step="0.01" v-model="edgeWidth"><br>
</div>
<div class="controls">
<h2>Help</h2>
<ul>
<li><kbd>Shift+Click</kbd> on edge => add point;</li>
<li><kbd>{{ useCtrl ? "Ctrl": "Cmd"}}+Click</kbd> on vertex => select/deselect it;</li>
<li><kbd>Alt+Click</kbd> on vertex => select/deselect all.</li>
<li><kbd>{{ useCtrl ? "Ctrl": "Cmd"}}+A</kbd> => select/deselect it;</li>
</ul>
<div class="github-logo">
<a href="https://github.com/ktzanev/mahler2d">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 92 92">
<path fill="gray" d="M62 52.5c-3.7 0-6.6 4-6.6 9s3 9 6.5 9 6.4-4 6.4-9-3-9-6.5-9zM84.4 29c.8-1.7.8-12-3-22 0 0-9.2 1-23 10.4-2.8-.8-7.6-1.2-12.5-1.2s-9.7.4-12.6 1.2C19.7 8 10.6 7 10.6 7c-4 10-4 20.3-3 22C2.7 34.3 0 40.3 0 48.6 0 84.5 29.8 85 37.3 85h17.4c7.5 0 37.3-.6 37.3-36.5 0-8.3-2.8-14.3-7.5-19.4zM46 80.7c-19 0-33.7-2.3-33.7-20.6 0-4.4 1.6-8.5 5.2-12 6.2-5.5 16.6-2.5 28.4-2.5 12 0 22.3-3 28.5 2.6 3.6 3.5 5.2 7.6 5.2 12C79.7 78.3 65 80.6 46 80.6zm-16-28c-3.5 0-6.4 4-6.4 9s3 9 6.5 9c3.7 0 6.6-4 6.6-9s-3-9-6.5-9z"/>
</svg>
</a>
</div>
</div>
</div>
</div>
<!-- JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.28/vue.min.js" /></script>
<script src="polygone.js"></script>
<script src="santalo.js"></script>
<script src="main.js"></script>
</body>
</html>