Repository navigation
Expand file tree
/
Copy patharray-sweeps.html
More file actions
288 lines (286 loc) · 21.6 KB
/
Copy patharray-sweeps.html
File metadata and controls
288 lines (286 loc) · 21.6 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Arrays on the quarter turn</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Serif+Display&display=swap">
<!--
array-sweeps.html: the four kinds of array laid on the two sweeps (24 October 2026, Tom: "create a demo of the arrays
on the sweeps"; SPN R483–R486; OFS §7.3, "The situations as arrays" and "Laid on the sweeps: a worked example"). A
standalone page, plain canvas. K places on the quarter turn; a direction (h, v) from home has the index
k = ⌊K·(2/π)·arctan(v/h)⌋ (atan2 in code, the horizon kept in the last place), no length entering. On the Thales
circle on the chord from home A to B the same point is met by the central sweep at 2θ from the centre, and its index
there, ⌊K·φ/π⌋, is the same place (Euclid III.20). The array strip shows the four kinds on those places: the index
alone (situation 4, nothing stored; the corner the boundary between K/2 − 1 and K/2 for even K, a place centred on it
for odd K); the values on the index (situation 3, a shape's amounts read from its centre, kept as ln r less their mean,
unmoved by scaling the world, the mean moved by ln k); a constant array (situation 1, the radius at H everywhere,
nothing stored); an array of known length (situation 2, the writer's ⌊N·x/X⌋ needing X, against the turn index
⌊K·(2/π)·arctan(x/H)⌋ needing only H, the zoom).
Links: ?K=4|8|16|32|9&t=<θ in degrees>&kind=index|values|constant|length&H=<log10 H>&k=<log10 k>.
Test hook: window.__arraySweeps (turnIndex, centralIndex, bounds, middles, countIndex, shapeValues, read, set, state).
-->
<style>
:root { color-scheme: dark; --ground: #0c0c11; --panel: #14141b; --line: rgba(255,255,255,0.09); --ink: #c8c8d0;
--dim: #8a8a96; --bright: #e6e4ee; --gold: #d4a052; --teal: #8ce6cd; --red: #d96e5b; --violet: #b59cf0 }
* { box-sizing: border-box }
body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.5 'DM Mono', ui-monospace, monospace }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px }
h1 { font: 400 32px/1.1 'DM Serif Display', Georgia, serif; color: var(--bright); margin: 0 0 6px }
.lede { color: var(--dim); margin: 0 0 14px; max-width: 80ch }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 14px }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px }
button { max-width: 100%; font: inherit; color: var(--bright); background: #1d1d27; border: 1px solid var(--line);
border-radius: 6px; padding: 6px 10px; cursor: pointer; touch-action: manipulation }
button.on { border-color: var(--gold); color: var(--gold) }
label { color: var(--dim) }
input[type=range] { flex: 1 1 160px; min-width: 0; accent-color: var(--gold) }
canvas { width: 100%; display: block; border-radius: 6px; background: #000; touch-action: none }
.grid > * { min-width: 0 }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr } }
.cap { color: var(--dim); font-size: 12px; margin: 4px 0 8px }
.read { font-size: 13px; white-space: pre-wrap; margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; background: #0f0f15 }
.g { color: var(--gold) } .r { color: var(--teal) } .w { color: var(--violet) } .x { color: var(--red) } .b { color: var(--bright) }
.note { color: var(--dim); font-size: 12.5px; margin: 6px 0 0 }
code { color: var(--bright) }
a { color: var(--teal) }
</style>
</head>
<body>
<main>
<h1>Arrays on the quarter turn</h1>
<p class="lede">Lay K places on the quarter turn. A direction from home, read as the ratio v/h, goes to the place
<code>k = ⌊K·(2/π)·arctan(v/h)⌋</code>: its share of the turn times K. No length enters. Classically (Euclid III.20), the
radius from the centre of the circle meets the same point at twice the angle and gives it the same place: the
description of the dual hemispherical vantage (DHV), in angles, shown for comparison. Four kinds of array lie on
those places: the <span class="g">index alone</span>, the <span class="r">values on the index</span>, a
<span class="w">constant array</span>, and an <span class="b">array of known length</span>, whose index needs its extent.</p>
<div class="panel">
<div class="row"><label>K places</label>
<button data-K="4">4</button><button data-K="8">8</button><button data-K="9">9</button><button data-K="16">16</button><button data-K="32">32</button>
<span class="cap" style="margin:0">(tap the circle to point)</span></div>
<div class="row"><label for="t">the direction θ</label><input id="t" type="range" min="0" max="90" step="0.1" value="60">
<span id="tv" class="b"></span></div>
<div class="row"><label>the array</label>
<button data-kind="index">the index alone (4)</button><button data-kind="values">the values on it (3)</button>
<button data-kind="constant">a constant array (1)</button><button data-kind="length">known length (2)</button></div>
<div class="row"><label for="k">scale the world, k</label><input id="k" type="range" min="-3" max="3" step="0.01" value="0">
<span id="kv" class="b"></span><button id="k1">k = 1</button></div>
<div class="row" id="hrow"><label for="H">H, the zoom</label><input id="H" type="range" min="0" max="2" step="0.01" value="1">
<span id="Hv" class="b"></span></div>
<div class="grid">
<div><canvas id="cv1" height="430"></canvas><p class="cap">The chord from home A to B and the circle on it. Gold:
the K places from home, at equal angles; teal: the same places from the centre, at twice the
angle (the DHV's, for comparison). The lit place is the one the direction falls in, both ways.</p></div>
<div>
<div class="read" id="r1"></div>
<div class="read" id="r2"></div>
</div>
</div>
<canvas id="cv2" height="260"></canvas><p class="cap" id="cap2"></p>
</div>
<p class="note"><b>An iterator, not an index.</b> The place formula on this page, the floor of K times the share of the
sweep, uses the arctangent to go straight from a reading to a place. That is the DHV's index operator. A read
sweeps forward from where it stands and has only the next step; the formula is how the DHV lays the places out.</p>
<p class="note">Related: <a href="one-read.html">one turn, one read</a>, <a href="sweep-zero.html">counting from zero</a>,
<a href="depth.html">the floor's depth</a>, <a href="zoom.html">H is a zoom</a>. <a href="demos.html">All the demos</a>.</p>
</main>
<script>
(function () {
'use strict';
const $ = id => document.getElementById(id), P = new URLSearchParams(location.search);
const st = { K: 8, t: 60, kind: 'index', lH: 1, lk: 0 };
const rad = d => d * Math.PI / 180;
const kOf = () => Math.pow(10, st.lk), HOf = () => Math.pow(10, st.lH);
// a place is [k, k + 1) of its share times K; a reading on a boundary belongs to the upper place, so the floor is
// taken a hair above, or atan2's last bit (0.9999999999999999 for 1 at 11.25°, K = 8) puts it in the lower one
const place = (x, K) => Math.min(K - 1, Math.floor(x + 1e-9));
// the index from a direction: its share of the turn times K; the horizon kept in the last place
const turnIndex = (v, h, K) => place(K * (2 / Math.PI) * Math.atan2(v, h), K);
// the central sweep meets the same point at φ = 2θ and indexes it over its half turn
const centralIndex = (phi, K) => place(K * phi / Math.PI, K);
const bounds = K => Array.from({ length: K + 1 }, (_, i) => i === K ? Infinity : Math.tan(i * Math.PI / (2 * K)));
const middles = K => Array.from({ length: K }, (_, i) => Math.tan((i + 0.5) * Math.PI / (2 * K)));
// the writer's count index needs the extent X
const countIndex = (x, X, N) => Math.min(N - 1, Math.floor(N * x / X));
// a shape read from its centre: ln r = a0 + f(φ), the amounts r in the world's unit (times k)
const f = phi => 0.28 * Math.cos(2 * phi + 0.4) + 0.12 * Math.cos(3 * phi) + 0.06 * Math.cos(5 * phi + 1);
function shapeValues(K, k) {
k = k == null ? kOf() : k;
const r = Array.from({ length: K }, (_, i) => k * 3 * Math.exp(f((i + 0.5) * Math.PI / K)));
const l = r.map(Math.log), m = l.reduce((a, b) => a + b, 0) / K;
return { amounts: r, logMean: m, shape: l.map(x => x - m) };
}
const AMOUNTS = [10, 50, 99], X0 = 100;
function read() {
const t = rad(st.t), k = kOf(), h = Math.cos(t) * k, v = Math.sin(t) * k;
const ti = turnIndex(v, h, st.K), ci = centralIndex(2 * t, st.K);
const s = h > 1e-12 * k ? v / h : Infinity;
const rec = turnIndex(h, v, st.K);
return { h, v, s, g: (2 / Math.PI) * Math.atan2(v, h), index: ti, central: ci, reciprocal: rec };
}
function fit(cv) {
const dpr = Math.min(2, window.devicePixelRatio || 1), w = cv.clientWidth,
hh = Math.min(+(cv.dataset.h || (cv.dataset.h = cv.getAttribute('height'))), Math.round(w * (cv.id === 'cv2' ? 0.45 : 0.9)));
cv.width = Math.round(w * dpr); cv.height = Math.round(hh * dpr);
const g = cv.getContext('2d'); g.setTransform(dpr, 0, 0, dpr, 0, 0); return { g, w, h: hh };
}
let geo = null;
function draw1() {
const { g, w, h } = fit($('cv1')); g.clearRect(0, 0, w, h);
const sc = Math.min(w * 0.84, (h - 70) / 0.62), ox = (w - sc) / 2, oy = h - 44;
const X = p => [ox + sc * p[0], oy - sc * p[1]];
geo = { ox, oy, sc };
const K = st.K, rd = read(), A = X([0, 0]), B = X([1, 0]), O = X([0.5, 0]);
const onCircle = phi => [0.5 + 0.5 * Math.cos(phi), 0.5 * Math.sin(phi)];
// the lit place: the sector from home and the arc it lands on
const lo = rd.index * Math.PI / (2 * K), hi = (rd.index + 1) * Math.PI / (2 * K);
g.fillStyle = 'rgba(212,160,82,0.16)'; g.beginPath(); g.moveTo(...A);
for (let i = 0; i <= 30; i++) { const a = lo + (hi - lo) * i / 30, phi = 2 * a; g.lineTo(...X(onCircle(phi))); }
g.closePath(); g.fill();
g.fillStyle = 'rgba(140,230,205,0.12)'; g.beginPath(); g.moveTo(...O);
for (let i = 0; i <= 30; i++) { const a = lo + (hi - lo) * i / 30, phi = 2 * a; g.lineTo(...X(onCircle(phi))); }
g.closePath(); g.fill();
// chord and circle
g.strokeStyle = 'rgba(230,228,238,0.7)'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(...A); g.lineTo(...B); g.stroke();
g.strokeStyle = 'rgba(230,228,238,0.35)'; g.lineWidth = 1; g.beginPath();
for (let i = 0; i <= 180; i++) { const q = X(onCircle(Math.PI * i / 180)); i ? g.lineTo(...q) : g.moveTo(...q); } g.stroke();
// the place boundaries: from home at jπ/2K, from the centre at twice that (A's ray at angle a meets the circle at
// (cos²a, cos a·sin a), the central angle 2a from B's side)
for (let j = 0; j <= K; j++) {
const a = j * Math.PI / (2 * K), P1 = X(onCircle(2 * a));
const corner = Math.abs(2 * j - K) < 1e-9;
g.strokeStyle = corner ? 'rgba(212,160,82,0.9)' : 'rgba(212,160,82,0.35)'; g.lineWidth = corner ? 1.6 : 1;
g.beginPath(); g.moveTo(...A); g.lineTo(...P1); g.stroke();
g.strokeStyle = 'rgba(140,230,205,0.3)'; g.lineWidth = 1; g.beginPath(); g.moveTo(...O); g.lineTo(...P1); g.stroke();
}
// place labels along the arc (when there is room)
if (K <= 16) {
g.font = '11px DM Mono, monospace'; g.fillStyle = '#8a8a96';
for (let j = 0; j < K; j++) {
const a = (j + 0.5) * Math.PI / (2 * K), p = onCircle(2 * a), q = X([0.5 + 0.56 * (p[0] - 0.5) / 0.5, 0.56 * p[1] / 0.5]);
g.fillStyle = j === rd.index ? '#e6e4ee' : '#8a8a96'; g.fillText(String(j), q[0] - 4, q[1] + 4);
}
}
// the direction: the ray from home and the radius from the centre to the one point
const t = rad(st.t), pt = onCircle(2 * t);
g.strokeStyle = '#d4a052'; g.lineWidth = 2.2; g.beginPath(); g.moveTo(...A); g.lineTo(...X([1.15 * Math.cos(t), 1.15 * Math.sin(t)])); g.stroke();
g.strokeStyle = '#8ce6cd'; g.lineWidth = 2.2; g.beginPath(); g.moveTo(...O); g.lineTo(...X(pt)); g.stroke();
const dot = (p, col, r) => { g.fillStyle = col; g.beginPath(); g.arc(p[0], p[1], r, 0, 2 * Math.PI); g.fill(); };
dot(X(pt), '#e6e4ee', 5); dot(A, '#e6e4ee', 4); dot(B, '#e6e4ee', 3); dot(O, '#8a8a96', 3);
g.font = '12px DM Mono, monospace'; g.fillStyle = '#e6e4ee';
g.fillText('A, home', A[0] - 8, A[1] + 18); g.fillText('B', B[0] - 4, B[1] + 18); g.fillText('centre', O[0] - 22, O[1] + 18);
g.fillStyle = '#d4a052'; g.fillText(`place ${rd.index} from home`, 12, 20);
g.fillStyle = '#8ce6cd'; g.fillText(`place ${rd.central} from the centre`, 12, 38);
if (K % 2 === 0) { g.fillStyle = 'rgba(212,160,82,0.9)'; g.fillText('the corner, 45°', 12, 56); }
else { g.fillStyle = 'rgba(212,160,82,0.9)'; g.fillText(`place ${(K - 1) / 2} centred on the corner`, 12, 56); }
}
function draw2() {
const { g, w, h } = fit($('cv2')); g.clearRect(0, 0, w, h);
const K = st.K, rd = read(), pad = 18, cw = (w - 2 * pad) / K, top = 40, ch = Math.min(110, h - 120);
g.font = '11px DM Mono, monospace';
const B = bounds(K), M = middles(K);
// the cells
for (let i = 0; i < K; i++) {
const x = pad + i * cw;
g.fillStyle = i === rd.index ? 'rgba(212,160,82,0.22)' : 'rgba(255,255,255,0.03)'; g.fillRect(x + 1, top, cw - 2, ch);
g.strokeStyle = 'rgba(255,255,255,0.12)'; g.strokeRect(x + 0.5, top + 0.5, cw - 1, ch - 1);
if (cw > 18) { g.fillStyle = i === rd.index ? '#e6e4ee' : '#8a8a96'; g.fillText(String(i), x + cw / 2 - 4, top - 6); }
}
// the corner
const cx = K % 2 === 0 ? pad + (K / 2) * cw : pad + ((K - 1) / 2 + 0.5) * cw;
g.strokeStyle = '#d4a052'; g.lineWidth = 1.5; g.setLineDash([4, 3]); g.beginPath(); g.moveTo(cx, top - 2); g.lineTo(cx, top + ch + 2); g.stroke(); g.setLineDash([]);
g.fillStyle = '#d4a052'; g.fillText('corner, v/h = 1', Math.min(w - 110, cx + 4), top + ch + 14);
// the boundaries' readings, when there is room
if (K <= 9) {
g.fillStyle = '#8a8a96';
for (let i = 0; i <= K; i++) { const x = pad + i * cw, lab = isFinite(B[i]) ? B[i].toFixed(3) : '∞'; g.fillText(lab, Math.max(0, Math.min(w - 40, x - 14)), top + ch + 30); }
g.fillStyle = 'rgba(140,230,205,0.8)';
for (let i = 0; i < K; i++) { const x = pad + (i + 0.5) * cw; g.fillText(M[i].toFixed(2), x - 14, top + ch + 46); }
}
let cap = '';
const k = kOf();
if (st.kind === 'index') {
g.fillStyle = '#8a8a96'; for (let i = 0; i < K; i++) if (cw > 40) g.fillText('—', pad + (i + 0.5) * cw - 4, top + ch / 2);
cap = `The index alone: ${K} places, nothing stored, no length. Grey under the boundaries: v/h at each boundary, tan(kπ/${2 * K}); teal: each place's middle, the half-Cauchy's ${K} evenly spaced quantiles. A reading and its reciprocal go to places k and ${K - 1} − k.`;
} else if (st.kind === 'values') {
const sv = shapeValues(K), mx = Math.max(...sv.shape.map(Math.abs)) || 1, mid = top + ch / 2;
g.strokeStyle = 'rgba(255,255,255,0.2)'; g.beginPath(); g.moveTo(pad, mid); g.lineTo(w - pad, mid); g.stroke();
for (let i = 0; i < K; i++) {
const x = pad + i * cw, y = sv.shape[i] / mx * (ch / 2 - 6);
g.fillStyle = 'rgba(140,230,205,0.75)'; g.fillRect(x + cw * 0.2, Math.min(mid, mid - y), cw * 0.6, Math.abs(y));
}
cap = `The values on the index: a shape read from its centre, one amount r a place (r at place ${rd.index}: ${sv.amounts[rd.index].toPrecision(4)}). Kept as ln r less their mean: these bars, unmoved by scaling the world. The mean of ln r is ${sv.logMean.toFixed(4)}; it moves by ln k = ${Math.log(k).toFixed(4)}, the one number no reading gives.`;
} else if (st.kind === 'constant') {
for (let i = 0; i < K; i++) { const x = pad + i * cw; g.fillStyle = 'rgba(181,156,240,0.7)'; g.fillRect(x + cw * 0.2, top + 10, cw * 0.6, ch - 20); }
cap = `A constant array: every place holds the radius, the read's one length H, 1. Nothing is stored; the value is a function of the index alone, and the array is the equation h² + v² = 1.`;
} else {
const X = X0 * k, H = HOf(), y0 = top + ch + 62;
// the writer's line [0, X] in N = K cells
g.strokeStyle = 'rgba(230,228,238,0.6)'; g.beginPath(); g.moveTo(pad, y0); g.lineTo(w - pad, y0); g.stroke();
for (let i = 0; i <= K; i++) { const x = pad + (w - 2 * pad) * i / K; g.beginPath(); g.moveTo(x, y0 - 4); g.lineTo(x, y0 + 4); g.stroke(); }
g.fillStyle = '#e6e4ee'; g.fillText(`the DHV's line, 0 to X = ${X.toPrecision(3)}, ${K} cells`, pad, y0 + 18);
const rows = [];
for (const a of AMOUNTS) {
const x = a * k, ci = countIndex(x, X, K), ti = turnIndex(x, H, K);
const px = pad + (w - 2 * pad) * x / X;
g.fillStyle = '#e6e4ee'; g.beginPath(); g.arc(px, y0, 4, 0, 2 * Math.PI); g.fill();
// its turn place in the strip
g.fillStyle = 'rgba(230,228,238,0.85)'; g.beginPath(); g.arc(pad + (ti + 0.5) * cw, top + ch / 2 + (AMOUNTS.indexOf(a) - 1) * 18, 5, 0, 2 * Math.PI); g.fill();
rows.push(`${x.toPrecision(3)}: count ${ci}, turn ${ti}`);
}
cap = `An array of known length: an amount x goes to ⌊N·x/X⌋, which needs X; read from home with distance laid by H, x goes to ⌊K·(2/π)·arctan(x/H)⌋, which needs only H (white dots in the strip). ${rows.join('; ')}. Scaling the world moves the amounts and X together, so the count index stays; the turn index moves unless H is scaled too: H is the zoom.`;
}
$('cap2').textContent = cap;
}
const f4 = x => !isFinite(x) ? '∞' : Math.abs(x) >= 1e5 || (Math.abs(x) < 1e-3 && x !== 0) ? x.toExponential(3) : x.toFixed(4);
function hud() {
const rd = read(), K = st.K;
$('tv').textContent = st.t.toFixed(1) + '°';
$('kv').textContent = kOf().toPrecision(3);
$('Hv').textContent = HOf().toPrecision(3);
$('hrow').style.display = st.kind === 'length' ? '' : 'none';
$('r1').innerHTML = `<span class="g">From home</span>: the direction [h : v] = [${f4(rd.h)} : ${f4(rd.v)}]\n`
+ ` v/h = ${f4(rd.s)}, its share of the turn g = (2/π)·arctan(v/h) = ${rd.g.toFixed(4)}\n`
+ ` index k = ⌊${K}·g⌋ = <span class="b">${rd.index}</span>${rd.s === Infinity ? ' (the horizon, kept in the last place)' : ''}\n`
+ ` its reciprocal h/v goes to place ${rd.reciprocal}` + (K % 2 === 0 || rd.index !== (K - 1) / 2 ? `, ${K - 1} − k` : '');
$('r2').innerHTML = `<span class="r">From the centre</span> (classically, the radius at twice the angle; the DHV's): the same point at φ = 2θ = ${(2 * st.t).toFixed(1)}°\n`
+ ` index ⌊${K}·φ/π⌋ = <span class="b">${rd.central}</span>: the same place\n`
+ `Scaling the world by k = ${kOf().toPrecision(3)} multiplies h and v together and moves no index.`;
}
function draw() {
draw1(); draw2(); hud(); $('t').value = st.t; $('k').value = st.lk; $('H').value = st.lH;
document.querySelectorAll('[data-K]').forEach(b => b.classList.toggle('on', +b.dataset.K === st.K));
document.querySelectorAll('[data-kind]').forEach(b => b.classList.toggle('on', b.dataset.kind === st.kind));
}
$('t').oninput = e => { st.t = +e.target.value; draw(); };
$('k').oninput = e => { st.lk = +e.target.value; draw(); };
$('H').oninput = e => { st.lH = +e.target.value; draw(); };
$('k1').onclick = () => { st.lk = 0; draw(); };
document.querySelectorAll('[data-K]').forEach(b => b.onclick = () => { st.K = +b.dataset.K; draw(); });
document.querySelectorAll('[data-kind]').forEach(b => b.onclick = () => { st.kind = b.dataset.kind; draw(); });
$('cv1').addEventListener('pointerdown', e => {
if (!geo) return; const r = e.target.getBoundingClientRect();
const x = (e.clientX - r.left - geo.ox) / geo.sc, y = (geo.oy - (e.clientY - r.top)) / geo.sc;
st.t = Math.max(0, Math.min(90, Math.atan2(Math.max(0, y), Math.max(0, x)) * 180 / Math.PI)); draw();
});
window.addEventListener('resize', draw);
function set(o) {
if ('K' in o) st.K = +o.K; if ('t' in o) st.t = +o.t; if ('kind' in o) st.kind = o.kind;
if ('H' in o) st.lH = Math.log10(+o.H); if ('k' in o) st.lk = Math.log10(+o.k);
draw(); return read();
}
if (P.has('K')) st.K = Math.max(2, Math.min(64, Math.round(+P.get('K')) || 8));
if (P.has('t')) st.t = Math.max(0, Math.min(90, +P.get('t')));
if (['index', 'values', 'constant', 'length'].includes(P.get('kind'))) st.kind = P.get('kind');
if (P.has('H')) st.lH = Math.max(0, Math.min(2, +P.get('H')));
if (P.has('k')) st.lk = Math.max(-3, Math.min(3, +P.get('k')));
draw();
window.__arraySweeps = { turnIndex, centralIndex, bounds, middles, countIndex, shapeValues, read, set,
state: () => ({ K: st.K, t: st.t, kind: st.kind, H: HOf(), k: kOf() }) };
})();
</script>
</body>
</html>