An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(linear-algebra): chapters 11-13 reviewed, with playgrounds
yzr1808eff212d3
diff --git a/site/linear-algebra/ch11/audio/en/play.mp3 b/site/linear-algebra/ch11/audio/en/play.mp3new file mode 100644index 0000000..d7fceedBinary files /dev/null and b/site/linear-algebra/ch11/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch11/audio/en/tilt.mp3 b/site/linear-algebra/ch11/audio/en/tilt.mp3index 31a5b98..45a5a51 100644Binary files a/site/linear-algebra/ch11/audio/en/tilt.mp3 and b/site/linear-algebra/ch11/audio/en/tilt.mp3 differdiff --git a/site/linear-algebra/ch11/audio/en/timings.js b/site/linear-algebra/ch11/audio/en/timings.jsindex 89225f3..f9f1f61 100644--- a/site/linear-algebra/ch11/audio/en/timings.js+++ b/site/linear-algebra/ch11/audio/en/timings.js@@ -521,18 +521,18 @@ window.TIMINGS = {]},"tilt": {- "dur": 57.696,+ "dur": 58.776,"marks": {- "three": 4.128,- "tilt": 10.729,- "why": 12.148,- "xa": 16.576,- "same": 23.685,- "zc": 32.826,- "zt": 38.685,- "minus": 44.206,- "neg": 48.177,- "sum": 52.07+ "three": 4.505,+ "tilt": 11.081,+ "why": 12.591,+ "xa": 17.031,+ "same": 24.232,+ "zc": 33.073,+ "zt": 39.206,+ "minus": 44.727,+ "neg": 48.503,+ "sum": 52.878},"cues": [[@@ -540,51 +540,51 @@ window.TIMINGS = {"The numbers in front of x, y and z do something else."],[- 4.128,+ 4.505,"Change x plus y plus z equals three into three x plus y plus z equals three."],[- 10.729,+ 11.081,"The plane tilts."],[- 12.148,+ 12.591,"Here is why."],[- 13.125,+ 13.555,"On the x axis, y and z are zero, so three x equals three, and x is one."],[- 20.182,+ 20.716,"The plane used to cross at three."],[- 22.188,+ 22.747,"Now it crosses at one."],[- 23.685,+ 24.232,"On the y axis and the z axis, nothing changed: they still cross at three."],[- 29.896,+ 30.273,"So the plane swings, like a door on a hinge."],[- 32.826,+ 33.073,"Now put the three in front of z instead: x plus y plus three z equals three."],[- 38.685,+ 39.206,"This time the z crossing moves down to one, and the plane leans the other way."],[- 44.206,- "And with negative x plus y plus z equals three, the x crossing jumps to negative three, behind the origin."+ 44.727,+ "And with negative x plus y plus z equals three, the x crossing jumps to negative three, on the other side of the origin."],[- 52.07,+ 52.878,"So the right side slides the plane, and the numbers in front of x, y and z tilt it."]]@@ -770,6 +770,30 @@ window.TIMINGS = {]]},+ "play": {+ "dur": 11.016,+ "marks": {+ "go": 4.036+ },+ "cues": [+ [+ 0.091,+ "Playground."+ ],+ [+ 1.055,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.036,+ "Change the numbers, drag the plane, turn the space, and see what moves with what."+ ],+ [+ 9.362,+ "Press continue when you're done."+ ]+ ]+ },"finish": {"dur": 12.456,"marks": {},diff --git a/site/linear-algebra/ch11/index.html b/site/linear-algebra/ch11/index.htmlindex 92cb2d8..ab4924d 100644--- a/site/linear-algebra/ch11/index.html+++ b/site/linear-algebra/ch11/index.html@@ -12,6 +12,7 @@<script src="../lib/math.js"></script><script src="../lib/linsys.js"></script><script src="../lib/space3.js"></script>+<script src="../lib/play.js"></script><script src="audio/en/timings.js"></script><script>'use strict';@@ -154,12 +155,12 @@ const BEATS = [text(p, 'x first, then y, then z', 1160, 486, m('tri') + 3, { size: 24, fill: COL.dim, anchor: 'middle' });const tl = text(p, 'a triple', 1030, 400, m('r2') - 2.2, { size: 26, fill: COL.task, anchor: 'middle', weight: 600 });hide(tl, m('r2') + 1.5, .4);- [[0, 0, 1], [1, 0, 2], [3, 1, -1], [0.5, 0.5, 2], [-1, 2, 2], [4, -2, 1]].forEach((r, i) => {- const c = chip(p, [tri(r)], COL.dim, { x: 990 + (i % 3) * 190, y: 540 + Math.floor(i / 3) * 70, size: 26 });+ [[0, 0, 1], [1, 0, 2], [3, 1, -1], [5, -1, -1], [-1, 2, 2], [4, -2, 1]].forEach((r, i) => {+ const c = chip(p, [tri(r)], COL.dim, { x: 990 + (i % 3) * 190, y: 580 + Math.floor(i / 3) * 66, size: 26 });put(c, { o: 0, s: .5 }); tw(c, { o: .8, s: 1 }, m('many') + .6 + i * .45, .4, back);});- text(p, '… and endlessly many more', 1180, 700, m('many') + 3.6, { size: 30, fill: COL.task, anchor: 'middle', weight: 600 });- text(p, 'a pair is a point on a flat plane. A triple?', 1180, 790, m('many') + 7, { size: 30, fill: COL.chalk, anchor: 'middle', weight: 600 });+ text(p, '… and endlessly many more', 1180, 730, m('many') + 3.6, { size: 30, fill: COL.task, anchor: 'middle', weight: 600 });+ text(p, 'a pair is a point on a flat plane. A triple?', 1180, 805, m('many') + 7, { size: 30, fill: COL.chalk, anchor: 'middle', weight: 600 });}],['space', 'Space has three directions', (m) => {@@ -167,10 +168,12 @@ const BEATS = [text(p, 'A third direction: up', 60, 110, .2, { size: 40, weight: 600 });const V = S.V = space3(p, { yaw: 0, pitch: 90, t0: .1 });put(V.axes[2], { o: 0 }); put(V.cube, { o: 0 });+ V.poly([[-4, -4, 0], [4, -4, 0], [4, 4, 0], [-4, 4, 0]], { color: COL.chalk, fo: .06, w: 0 }); // the sheet of paper that is laid downconst pt = V.point([2, 1, 0], { color: COL.task, label: '(2, 1)' });// the walk of chapter 1, on the flat plane seen from aboveV.walk([2, 1, 0], m('pt'), { dur: 1.4, dot: false, w: 4 });- say(p, ['(2, 1)'], 90, 210, m('pt') + .6, { size: 46, fill: COL.task });+ const p2 = say(p, ['(2, 1)'], 90, 210, m('pt') + .6, { size: 46, fill: COL.task });+ hide(p2, m('floor') + .3, .3); say(p, ['(2, 1, 0)'], 90, 210, m('floor') + .5, { size: 46, fill: COL.task });put(pt.e, { o: 0 }); show(pt.e, m('pt') + 1.3, .3);[[0, 'xr'], [1, 'yu']].forEach(([j, mk_]) => {const a = V.line(null, null, { color: AXC[j], w: 7, into: V.content, head: true }), e = [0, 0, 0];@@ -192,7 +195,7 @@ const BEATS = [tw(V.floor, { 'a_stroke-opacity': .35 }, m('floor'), .4); tw(V.floor, { 'a_stroke-opacity': .09 }, m('floor') + 1.4, .8);prog(() => { pt.label('(2, 1, 0)'); }, m('floor') + .5, 0, lin);V.sway(4, 9, m('lay') + 2.6);- V.turn({ yaw: VIEW.yaw - 25, pitch: VIEW.pitch }, m('turn'), 3.2);+ V.turn({ yaw: VIEW.yaw - 15, pitch: VIEW.pitch }, m('turn'), 3.2); // not below 15: y would run up the z axisV.turn({ yaw: VIEW.yaw + 20 }, m('turn') + 3.2, 3.6);V.turn({ yaw: VIEW.yaw }, m('turn') + 6.8, 2.4);}],@@ -205,7 +208,7 @@ const BEATS = [say(p, ['(2, 1, 3)'], 90, 210, .4, { size: 54, fill: COL.task });const O = V.point(null, { color: COL.chalk, r: 7 });prog(() => O.set([0, 0, 0]), m('o'), 0, lin); pulse(O.e, m('o'));- const w1 = V.walk([2, 1, 3], 0, { at: [m('x'), m('y'), m('z')], dur: 3, label: '(2, 1, 3)' });+ const w1 = V.walk([2, 1, 3], 0, { at: [m('x'), m('y'), m('z')], dur: 3, label: '(2, 1, 3)', w: 8 });const steps = [['2', 'steps along x'], ['1', 'step along y, away'], ['3', 'steps up']];const st1 = G(p, {});steps.forEach(([n, s], j) => { say(st1, [n], 110, 300 + j * 56, m(['x', 'y', 'z'][j]), { size: 40, fill: AXC[j], anchor: 'middle' }); text(st1, s, 150, 300 + j * 56, m(['x', 'y', 'z'][j]) + .2, { size: 28, fill: COL.dim }); });@@ -218,7 +221,7 @@ const BEATS = [[st1, sn].forEach(e => hide(e, m('ex2') - .4, .4));tw(w1.dot.e, { o: .5 }, m('ex2'), .4);say(p, ['(−1, 2, −2)'], 360, 210, m('ex2'), { size: 54, fill: COL.int });- const w2 = V.walk([-1, 2, -2], 0, { at: [m('x2'), m('y2'), m('z2')], dur: 3, label: '(−1, 2, −2)', color: COL.int });+ const w2 = V.walk([-1, 2, -2], 0, { at: [m('x2'), m('y2'), m('z2')], dur: 3, label: '(−1, 2, −2)', color: COL.int, w: 8 });const steps2 = [['−1', 'step along x: to the left'], ['2', 'steps along y, away'], ['−2', 'steps: down, below the floor']];steps2.forEach(([n, s], j) => { say(p, [n], 110, 300 + j * 56, m(['x2', 'y2', 'z2'][j]), { size: 40, fill: AXC[j], anchor: 'middle' }); text(p, s, 150, 300 + j * 56, m(['x2', 'y2', 'z2'][j]) + .2, { size: 28, fill: COL.dim }); });pulse(w2.dot.e, m('here2'));@@ -350,7 +353,11 @@ const BEATS = [text(p, 'Change the right side', 60, 110, .2, { size: 40, weight: 600 });const sys = S.sys = onePlane(p, 1, 1, 1, 3);const V = sys.space;- crossings(sys, m('three'));+ crossings(sys, m('three'), { labels: false });+ const rd = G(p, { o: 0 }), rdT = T(rd, '', { x: 90, y: 400, size: 34, fill: COL.task, font: MATH });+ T(rd, 'where it crosses the axes:', { x: 90, y: 350, size: 28, fill: COL.dim });+ sys.onChange(v => { const c = r1(v.b0); const s = `(${num(c)}, 0, 0), (0, ${num(c)}, 0), (0, 0, ${num(c)})`; if (rdT.textContent !== s) rdT.textContent = s; });+ show(rd, m('three'));const ghost = V.poly(null, { color: BLUE, fo: 0, w: 2, into: V.content });ghost.e.setAttribute('stroke-dasharray', '8 8'); ghost.e.setAttribute('stroke-opacity', .5);const keep = (d, t) => prog(() => ghost.set(S3_cut(1, 1, 1, d, V.R)), t, 0, lin);@@ -358,12 +365,12 @@ const BEATS = [sys.to({ b0: 1 }, m('one'), 1.6); flash(sys, 'b0', m('one'));keep(1, m('zero'));sys.to({ b0: 0 }, m('zero'), 1.4); flash(sys, 'b0', m('zero'));- say(p, ['0 + 0 + 0 = 0'], 90, 330, m('origin'), { size: 38, fill: COL.task });+ const zz = say(p, ['0 + 0 + 0 = 0'], 90, 460, m('origin'), { size: 38, fill: COL.task }); hide(zz, m('neg'), .3);keep(0, m('neg'));sys.to({ b0: -2 }, m('neg'), 1.4); flash(sys, 'b0', m('neg'));const n = G(p, { o: 0 });- T(n, 'right side changes:', { x: 90, y: 460, size: 32, fill: COL.dim });- T(n, 'the plane slides, never tilts', { x: 90, y: 510, size: 36, weight: 600, fill: COL.task });+ T(n, 'right side changes:', { x: 90, y: 500, size: 32, fill: COL.dim });+ T(n, 'the plane slides, never tilts', { x: 90, y: 550, size: 36, weight: 600, fill: COL.task });show(n, m('par'));V.sway(10, 14, 0);}],@@ -393,13 +400,16 @@ const BEATS = [T(n, 'right side: slides the plane', { x: 90, y: 630, size: 34, weight: 600, fill: COL.task });T(n, 'numbers in front of x, y, z: tilt it', { x: 90, y: 682, size: 34, weight: 600, fill: BLUE });show(n, m('sum'));- V.sway(9, 15, 0);+ V.turn({ pitch: 50 }, m('zc'), 2); // x + y + 3z = 3 is edge-on at pitch 24+ V.turn({ yaw: -20, pitch: 26 }, m('minus'), 2.2); // −x + y + z = 3 is edge-on at yaw 30+ V.turn({ yaw: VIEW.yaw, pitch: VIEW.pitch }, m('sum') + 1, 2.4);+ V.sway(6, 15, 0);}],['q2', 'Quick check', () => {const p = panel(0);text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });- S.sys = onePlane(p, 1, 2, 4, 4);+ S.sys = onePlane(p, 1, 2, 4, 4, { view: { yaw: 30, pitch: 45 } }); // at the base pitch this plane is nearly edge-onS.sys.space.sway(6, 14);}, { ask: done => quiz(CARD, [{id: 'c-cross', prompt: ['Where does ', $m('x + 2y + 4z = 4'), ' cross the three axes?'],@@ -433,6 +443,7 @@ const BEATS = [hide(f2, m('eq3') - .4, .3);// x + y = 2: first the line on the floor, then the wall that rises from itprog(() => { pl.visible = false; V.redraw(); }, m('eq3') - .3, 0, lin);+ V.turn({ yaw: VIEW.yaw, pitch: 34 }, m('eq3'), 1.8);sys.to({ a01: 1, b0: 2 }, m('eq3'), .1);flash(sys, 'a02', m('eq3') + .5);const ln = V.line(null, null, { color: BLUE, w: 6, into: V.content });@@ -442,7 +453,7 @@ const BEATS = [const wl = V.poly(null, { color: BLUE, fo: .22, w: 3, into: V.polys });prog(q => { const h = V.R * q; wl.set(q ? [[4, -2, -h], [-2, 4, -h], [-2, 4, h], [4, -2, h]] : null); }, m('rise'), 2.2, io);[-1, 1, 3].forEach((x, i) => { const d = V.point(null, { color: COL.task, r: 7, into: V.content }); prog(() => d.set([x, 2 - x, [3, -2, 1.5][i]]), m('free') + 1 + i * .3, 0, lin); });- V.turn({ yaw: VIEW.yaw - 20, pitch: 16 }, m('rise'), 3);+ V.turn({ yaw: -15, pitch: 18 }, m('rise'), 3); // the wall x + y = 2 from 60° off face-on: it reads as standingtext(p, 'a missing letter = a free letter', 90, 690, m('sum'), { size: 32, weight: 600 });}],@@ -506,6 +517,15 @@ const BEATS = [build: lin3Task(S.sys, v => v.a02 === 0 && v.a00 !== 0 && v.a01 === -v.a00 && v.b0 === v.a00, 'x − y + 0z = 1: z is missing, so z is free and the line stands up.','A wall has no z: put 0 in front of z. Then the rest is the line x − y = 1.', () => S.sys.set({ a00: 1, a01: -1, a02: 0, b0: 1 })),}], done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ S.sys = onePlane(p, 1, 1, 1, 3);+ crossings(S.sys, .3);+ S.sys.space.sway(5, 16);+ const hint = text(p, 'try: make a floor, make it pass through (0, 0, 0), make a wall', 90, 330, m('go'), { size: 28, fill: COL.dim });+ hide(hint, m('go') + 7, .6);+ }, { ask: playAsk(() => S.sys, { tip: 'Your plane. Change any number, drag the plane by its edge, turn the space, or draw on the board. Nothing is marked.' }) }],['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));diff --git a/site/linear-algebra/ch12/audio/en/play.mp3 b/site/linear-algebra/ch12/audio/en/play.mp3new file mode 100644index 0000000..888567aBinary files /dev/null and b/site/linear-algebra/ch12/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch12/audio/en/timings.js b/site/linear-algebra/ch12/audio/en/timings.jsindex b781073..e0cf91d 100644--- a/site/linear-algebra/ch12/audio/en/timings.js+++ b/site/linear-algebra/ch12/audio/en/timings.js@@ -728,6 +728,30 @@ window.TIMINGS = {]]},+ "play": {+ "dur": 12.384,+ "marks": {+ "go": 4.089+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.081,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.089,+ "Change any number, drag a plane by its edge, turn the space, and watch where the planes meet."+ ],+ [+ 10.703,+ "Press continue when you're done."+ ]+ ]+ },"finish": {"dur": 12.528,"marks": {},diff --git a/site/linear-algebra/ch12/index.html b/site/linear-algebra/ch12/index.htmlindex 6e9041a..6676e9b 100644--- a/site/linear-algebra/ch12/index.html+++ b/site/linear-algebra/ch12/index.html@@ -12,6 +12,7 @@<script src="../lib/math.js"></script><script src="../lib/linsys.js"></script><script src="../lib/space3.js"></script>+<script src="../lib/play.js"></script><script src="audio/en/timings.js"></script><script>'use strict';@@ -104,9 +105,9 @@ const BEATS = [tw(g, { o: 1, y: 0 }, .2, 1.1, out);const r = text(scene, 'three equations in x, y, z: three planes, and the point they share', 800, 560, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });// three strokes that swing in and cross at one dot- const lg = G(scene, { x: 800, y: 700 });+ const lg = G(scene, { x: 800, y: 730 });S3_ROW.forEach((c, i) => {- const l = path(lg, 'M-150 0H150', { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round' });+ const l = path(lg, 'M-115 0H115', { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round' });put(l, { o: 0, r: 0 }); tw(l, { o: 1 }, m('sub') + 1 + i * .5, .4); tw(l, { r: [-35, 30, 85][i] }, m('sub') + 1 + i * .5, 1.6, soft);});tw(lg, { r: 25 }, m('sub') + 1, D - m('sub') - 1, soft);@@ -133,7 +134,7 @@ const BEATS = [const V = sys.space;V.sway(6, 14);// two tries, side by side- const P1 = V.point(null, { color: COL.chalk, label: '(0, 0, 1)', size: 26 }), P2 = V.point(null, { color: COL.chalk, label: '(1, 2, 4)', size: 26 });+ const P1 = V.point(null, { color: COL.chalk, label: '(0, 0, 1)', size: 26 }), P2 = V.point(null, { color: COL.chalk, label: '(1, 2, 4)', size: 26, stem: true });prog(() => P1.set([0, 0, 1]), m('try'), 0, lin); pulse(P1.e, m('try'));prog(() => P2.set([1, 2, 4]), m('try2'), 0, lin); pulse(P2.e, m('try2'));S.P1 = P1; S.P2 = P2;@@ -174,7 +175,7 @@ const BEATS = [hide(S.w, .1, .4);lit(sys, 1, m('eq2') - .3);const w = S.w = G(p, {});- const cr = tickCross(V, [[[1, 0, 0], '', 12, 30], [[0, -.5, 0], '(0, −½, 0)', -120, 4], [[0, 0, 1], '', -100, -14]], [m('cx') + 2.5, m('cy') + 2.8, m('cz') + 2.4], COL.task, w);+ const cr = tickCross(V, [[[1, 0, 0], '', 12, 30], [[0, -.5, 0], '(0, −½, 0)', -120, 4], [[0, 0, 1], ' ', -100, -14]], [m('cx') + 2.5, m('cy') + 2.8, m('cz') + 2.4], COL.task, w);say(w, ['x-axis: −x = −1, x = 1'], 90, 460, m('cx') + 1, { size: 30 });say(w, ['y-axis: 2y = −1, y = −', F(1, 2)], 90, 510, m('cy') + 1, { size: 30 });say(w, ['z-axis: −z = −1, z = 1'], 90, 560, m('cz') + 1, { size: 30 });@@ -192,7 +193,7 @@ const BEATS = [pulse(S.P1.e, m('both') + .5); pulse(S.P2.e, m('both') + 1.2);text(w2, 'two equations: a whole line of solutions', 90, 520, m('many'), { size: 30, fill: COL.task, weight: 600 });S.w = w2;- V.turn({ yaw: VIEW.yaw + 30 }, m('meet'), 3); V.turn({ yaw: VIEW.yaw }, m('many'), 2.5);+ V.turn({ yaw: VIEW.yaw + 20 }, m('meet'), 3); // not past −15: y would run up the z axis V.turn({ yaw: VIEW.yaw }, m('many'), 2.5);}],['p3', 'The third plane', (m) => {@@ -204,13 +205,17 @@ const BEATS = [text(w, 'x is missing: it runs along x', 90, 460, m('nox'), { size: 30, fill: COL.task, weight: 600 });say(w, ['z-axis: 4z = 4, z = 1'], 90, 515, m('cz'), { size: 30 });say(w, ['y-axis: −3y = 4, y = −', F(4, 3)], 90, 570, m('cy'), { size: 30 });- const cr = tickCross(V, [[[0, 0, 1], '', -100, -14], [[0, -4 / 3, 0], '(0, −4/3, 0)', -150, 4]], [m('cz') + .4, m('cy') + .6], COL.task, w);+ const cr = tickCross(V, [[[0, 0, 1], ' ', -100, -14], [[0, -4 / 3, 0], '(0, −4/3, 0)', -150, 4]], [m('cz') + .4, m('cy') + .6], COL.task, w);reveal(sys, 2, m('show'), 1);cr.forEach(d => hide(d.e, m('cut'), .4));lit(sys, [0, 1], m('cut') - .2); // the line of the first two, bright; the third plane dim while we look at the lineprog(q => sys.lines[0].e.setAttribute('stroke-width', 2.5 + 4 * Math.sin(Math.PI * q)), m('cut'), 1.4, lin);lit(sys, null, m('cut') + 2.4);- show(sys.meet.e, m('pt'), .3); pulse(sys.meet.e, m('pt')); pulse(sys.meet.e, m('pt') + 1);+ show(sys.meet.e, m('pt'), .3); pulse(sys.meet.e, m('pt')); pulse(sys.meet.e, m('pt') + 1); hide(S.P1.e, m('pt'), .3);+ // (1, 2, 4) is on the line of planes 1 and 2 but off plane 3: plane 3 alone, the line through it+ const ln = V.line(null, null, { color: COL.chalk, w: 4, dash: '10 8', clip: true });+ prog(() => ln.set([-2, -4, -5], [2, 4, 7]), m('miss'), 0, lin); tw(ln.e, { o: 0 }, 0, 0); show(ln.e, m('miss'), .4); hide(ln.e, m('only') + .4, .4);+ lit(sys, 2, m('miss')); lit(sys, null, m('only') + .4);show(sys.sol, m('pt') + .4, .5);hide(w, m('miss') - .3, .3);tw(S.P2.e, { o: 1 }, m('miss'), 0); tw(S.P2.e.firstChild, { c_fill: COL.bad }, m('miss'), .3); tw(S.P2.t, { c_fill: COL.bad }, m('miss'), .3);@@ -222,7 +227,10 @@ const BEATS = [['check', 'From all sides', (m) => {const sys = S.sys, V = sys.space;hide(S.P2.e, .1, .5); hide(S.P1.e, .1, .3);- V.turn({ yaw: VIEW.yaw - 25 + 340, pitch: 26 }, .3, m('ans') - .3, lin); // once round, slowly+ V.turn({ yaw: -95, pitch: 24 }, .3, m('f1') + .4); // the wall 2x − y = 0 nearly face-on+ V.turn({ yaw: -25, pitch: 24 }, m('f2'), 1.4); // plane 2 face-on+ V.turn({ yaw: 5, pitch: 36 }, m('f3'), 1.3); // plane 3 face-on+ V.turn({ yaw: -50, pitch: 28 }, m('lines'), 3); // all three well apartsys.focus(0, m('f1')); sys.focus(1, m('f2')); sys.focus(2, m('f3')); sys.focus(null, m('lines'));[m('f1'), m('f2'), m('f3')].forEach(t => pulse(sys.meet.e, t + .4));[0, 1, 2].forEach(i => prog(q => sys.lines[i].e.setAttribute('stroke-width', 2.5 + 3.5 * Math.sin(Math.PI * q)), m('lines') + i * .5, 1.2, lin));@@ -238,6 +246,7 @@ const BEATS = [const p = panel(0);text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });S.sys = three(p, LEC.A, LEC.b, { sol: false });+ put(S.sys.meet.t, { o: 0 }); // the meeting point unnamed: the reader checks (0, 0, 1) by putting it inS.sys.space.sway(6, 14);}, { ask: done => quiz(CARD, [{id: 'c-all', prompt: ['Does the point solve all three equations?'],@@ -307,7 +316,7 @@ const BEATS = [const old = V.point([0, 0, 1], { color: COL.dim, r: 7 });put(old.e, { o: 0 }); show(old.e, m('slide'), .3);pulse(sys.meet.e, m('new'));- say(p, ['−3·2 + 4·4 = −6 + 16 = 10 ✓'], 90, 480, m('old') + 4, { size: 30, fill: COL.good });+ const c10 = say(p, ['−3·2 + 4·4 = −6 + 16 = 10 ✓'], 90, 480, m('old') + 4, { size: 30, fill: COL.good }); hide(c10, m('back'), .3);sys.to({ b2: 4 }, m('back'), 2.2, io); flash(sys, 'b2', m('back'));V.turn({ yaw: VIEW.yaw + 20, pitch: 28 }, m('slide'), 4);}],@@ -337,7 +346,7 @@ const BEATS = [const a = text(p, 'z = 1 and z = 3 at once? Never.', 90, 470, m('two') + 2, { size: 30, fill: COL.bad, weight: 600 });sys.focus(null, m('nosol'));tw(sys.sol, { s: 1.06 }, m('nosol'), .3); tw(sys.sol, { s: 1 }, m('nosol') + .5, .4);- hide(a, m('eq2') - .4, .3);+ hide(a, m('eq2') - .4, .3); hide(sys.sol, m('eq2') - .4, .3); show(sys.sol, m('none'), .4);// switch to the tent: hide the planes, change the numbers, bring them backsys.planes.forEach(pl => { pl.fade(0, m('eq2') - .4, .3); pl.fade(1, m('eq2') + .5, .8); });sys.to({ a00: 1, a01: 0, a02: 1, a10: -1, a11: 0, a12: 1, a20: 0, a21: 0, a22: 1, b0: 2, b1: 2, b2: 0 }, m('eq2') - .1, .1, lin);@@ -354,14 +363,14 @@ const BEATS = [['line', 'A whole line', (m) => {const p = panel(0);text(p, 'When the planes share a line', 60, 110, .2, { size: 40, weight: 600 });- const sys = S.sys = three(p, [[1, -1, 0], [0, 1, -1], [1, 0, -1]], [0, 0, 0], { t0: m('eq') - .3, view: { yaw: -20, pitch: 22 } });+ const sys = S.sys = three(p, [[1, -1, 0], [0, 1, -1], [1, 0, -1]], [0, 0, 0], { t0: m('eq') - .3, view: { yaw: -60, pitch: 15 } });const V = sys.space;tw(sys.sol, { o: 0 }, 0, 0); show(sys.sol, m('many'), .4);V.sway(6, 12);const sp = V.line(null, null, { color: COL.task, w: 6, into: V.content });prog(q => sp.set([-4, -4, -4], [-4 + 8 * q, -4 + 8 * q, -4 + 8 * q]), m('spine'), 1.4, io);// look down the spine, like looking at a book from its end- V.turn({ yaw: -135, pitch: 35.3 }, m('spine') + 1.2, 3); V.turn({ yaw: -60, pitch: 24 }, m('pts') - .2, 2.6);+ V.turn({ yaw: -135, pitch: 35.3 }, m('spine') + 1.2, 3); V.turn({ yaw: -60, pitch: 15 }, m('pts') - .2, 2.6);[[1, 1, 1], [2, 2, 2], [-1, -1, -1]].forEach((q, i) => {const d = V.point(null, { color: COL.chalk, label: tri(q), size: 24 });const t = m('pts') + [0, 1.6, 3.2][i];@@ -435,6 +444,14 @@ const BEATS = ['Make the third plane parallel to the first: copy the first equation’s numbers in front of x, y and z. Then both say 2x − y equals something, but different somethings.',() => S.sys.set({ a20: 2, a21: -1, a22: 0 }), ['a20', 'a21', 'a22']),}], done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ S.sys = three(p, LEC.A, LEC.b);+ S.sys.space.sway(5, 16);+ const hint = text(p, 'try: move the meeting point to (1, 1, 1), make two planes parallel, make all three share a line', 90, 870, m('go'), { size: 26, fill: COL.dim });+ hide(hint, m('go') + 8, .6);+ }, { ask: playAsk(() => S.sys, { tip: 'Your three planes. Change any number, drag a plane by its edge, turn the space, or draw on the board. Nothing is marked.' }) }],['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));diff --git a/site/linear-algebra/ch13/audio/en/play.mp3 b/site/linear-algebra/ch13/audio/en/play.mp3new file mode 100644index 0000000..53569c9Binary files /dev/null and b/site/linear-algebra/ch13/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch13/audio/en/timings.js b/site/linear-algebra/ch13/audio/en/timings.jsindex 6511545..c96dc35 100644--- a/site/linear-algebra/ch13/audio/en/timings.js+++ b/site/linear-algebra/ch13/audio/en/timings.js@@ -676,6 +676,30 @@ window.TIMINGS = {]]},+ "play": {+ "dur": 12.024,+ "marks": {+ "go": 3.763+ },+ "cues": [+ [+ 0.091,+ "Playground."+ ],+ [+ 1.12,+ "Nothing here is marked right or wrong."+ ],+ [+ 3.763,+ "Change the mix, change a column, drag an arrow tip, turn the space, and watch b move."+ ],+ [+ 10.391,+ "Press continue when you're done."+ ]+ ]+ },"finish": {"dur": 9.864,"marks": {},diff --git a/site/linear-algebra/ch13/index.html b/site/linear-algebra/ch13/index.htmlindex ab587dc..44bba61 100644--- a/site/linear-algebra/ch13/index.html+++ b/site/linear-algebra/ch13/index.html@@ -12,6 +12,7 @@<script src="../lib/math.js"></script><script src="../lib/linsys.js"></script><script src="../lib/space3.js"></script>+<script src="../lib/play.js"></script><script src="audio/en/timings.js"></script><script>'use strict';@@ -20,7 +21,8 @@ const CHAPTER = { number: 13, title: 'Three Columns in Space', minutes: 13, lang/* ---------- chapter drawing helpers ---------- */const LEC = { A: [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b: [0, -1, 4] }; // the lecture's system; its columns are the arrowsconst COLS = [[2, -1, 0], [-1, 2, -3], [0, -1, 4]];-const VIEW = { yaw: 50, pitch: 20 }; // the three lecture columns land far apart on screen (at yaw −35 columns 1 and 2 nearly overlapped)+const VIEW = { yaw: 50, pitch: 20 };+const ROWV3 = { yaw: -35, pitch: 22 }; // the planes as chapter 12 showed them: at yaw 50 two of them are nearly edge-on // the three lecture columns land far apart on screen (at yaw −35 columns 1 and 2 nearly overlapped)const AXC = [COL.whole, COL.nat, COL.int]; // steps along x, y, z (chapter 11's walk)const CF_Y = 470; // the column form's top rowconst say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };@@ -138,11 +140,9 @@ const BEATS = [V.sway(3, 16);// the two equations, then the same numbers read down the columnsconst e1 = say(p, ['2x − y = 0'], 100, 200, m('eq') + .3, { size: 36 }), e2 = say(p, ['−x + 2y = 3'], 100, 250, m('e2'), { size: 36 });- const colBox = (x, w, c, t) => box(p, x, 162, w, 106, c, t, m('mix'));- hide(e1, m('read') + .2, .4); hide(e2, m('read') + .2, .4);+ const colBox = (x, w, c, t) => box(p, x, 312, w, 106, c, t, m('mix'));// x·[2, −1] + y·[−1, 2] = [0, 3], drawn as bracketed columns- const eq = G(p, { o: 0 });- // x·[2, −1] + y·[−1, 2] = [0, 3], drawn as bracketed columns, one part on each word+ const eq = G(p, { o: 0, y: 150 }); // under the equations, so each column is read straight down from themconst part = t => { const g = G(eq, { o: 0 }); show(g, t, .5); return g; };const cv = (g, nums, x, color) => {path(g, `M${x + 12} 172H${x}V268H${x + 12}M${x + 58} 172H${x + 70}V268H${x + 58}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });@@ -157,16 +157,15 @@ const BEATS = [[[a1, 'c1'], [a2, 'c2'], [ab, 'b']].forEach(([a, k]) => { tw(a.e, { o: 0 }, 0, 0); show(a.e, m(k), .5); });const lab = (q, s, c, t, dx, dy) => { const d = V.point(null, { color: c, r: 0.1, label: s, size: 26, dx, dy }); prog(() => d.set(q), t, 0, lin); };lab([2, -1, 0], 'col 1', S3_COLS[0], m('c1') + .3, 10, 26); lab([-1, 2, 0], 'col 2', S3_COLS[1], m('c2') + .3, -80, 0); lab([0, 3, 0], 'b', COL.task, m('b') + .3, 12, -6);- say(p, ['x = 1, y = 2'], 100, 340, m('mix'), { size: 40, fill: COL.task });+ say(p, ['x = 1, y = 2'], 100, 500, m('mix'), { size: 40, fill: COL.task });const l1 = V.arrow(null, null, { color: S3_COLS[0], w: 4, dash: '10 8' }), l2 = V.arrow(null, null, { color: S3_COLS[1], w: 4, dash: '10 8' });prog(q => l1.set([0, 0, 0], [2 * q, -q, 0]), m('one'), .9, io);prog(q => l2.set([2, -1, 0], [2 - 2 * q, -1 + 4 * q, 0]), m('two'), 1.4, io);- say(p, ['1·col 1 + 2·col 2 = b'], 100, 410, m('two') + .4, { size: 34 });+ say(p, ['1·col 1 + 2·col 2 = b'], 100, 565, m('two') + .4, { size: 34 });const land = V.point(null, { color: COL.task, r: 11 }); prog(() => land.set([0, 3, 0]), m('land'), 0, lin); pulse(land.e, m('land'));- V.turn({ yaw: VIEW.yaw, pitch: VIEW.pitch }, m('lay'), 2.8);- V.turn({ yaw: VIEW.yaw + 30 }, m('lay') + 3, 4);+ V.turn({ yaw: VIEW.yaw, pitch: 32 }, m('lay'), 2.8); // laid down, but high enough that the floor arrows stay apartshow(V.axes[2], m('lay') + 1.6, .6); show(V.cube, m('lay') + 2, .8);- text(p, 'now: room to point up and down', 100, 480, m('lay') + 2.4, { size: 30, fill: COL.int, weight: 600 });+ text(p, 'now: room to point up and down', 100, 640, m('lay') + 2.4, { size: 30, fill: COL.int, weight: 600 });}],['columns', 'Reading down the columns', (m, D) => {@@ -196,11 +195,11 @@ const BEATS = [V.sway(5, 13);[['w1', 'a1'], ['w2', 'a2'], ['w3', 'a3']].forEach(([w, a], j) => {const t = m(w), dt = Math.max(.9, (m(a) - t) / 3.4);- const wk = V.walk(COLS[j], 0, { at: [t + dt * .7, t + dt * 1.7, t + dt * 2.7], dur: 2.1, dot: false, w: 3 });+ const wk = V.walk(COLS[j], 0, { at: [t + dt * .7, t + dt * 1.7, t + dt * 2.7], dur: 2.1, dot: false, w: 6 });showArrow(sys, j, m(a) - .2);wk.legs.forEach(l => hide(l.e, m(a) + 1.4, .5));});- V.turn({ yaw: VIEW.yaw + 25 }, m('w2'), 2.5); V.turn({ yaw: VIEW.yaw - 10, pitch: 26 }, m('w3'), 2.5);+ V.turn({ yaw: VIEW.yaw - 25 }, m('w2'), 2.5); V.turn({ yaw: VIEW.yaw - 10, pitch: 26 }, m('w3'), 2.5);showArrow(sys, 3, m('bb'));prog(q => sys.bArrow.e.setAttribute('stroke-width', 9 + 5 * Math.sin(Math.PI * q)), m('same'), 1.2, lin);S.bcol = text(S.p, 'b is column 3!', 90, 680, m('same') + .3, { size: 34, fill: COL.task, weight: 600 });@@ -217,6 +216,7 @@ const BEATS = [[0, 1].forEach(j => { tw(sys.colG[j], { o: .3 }, m('chk'), .4); tw(sys.mixG[j], { o: .3 }, m('chk'), .4); tw(sys.colG[j], { o: 1 }, m('same'), .4); tw(sys.mixG[j], { o: 1 }, m('same'), .4); });box(p, cfColX(2) - 8, CF_Y - 40, 230, 150, COL.task, m('chk') + 6, m('same'));sys.view('row', m('same'), .6);+ sys.space.turn(ROWV3, m('same'), 1.6); sys.space.turn(VIEW, m('easy') + 4, 1.6);const s = text(p, 'the planes meet at (0, 0, 1): the same answer', 90, 680, m('same') + .3, { size: 30, fill: COL.chalk, weight: 600 });sys.view('col', m('easy') + 4, .6);hide(s, m('easy') + 4, .4);@@ -229,7 +229,8 @@ const BEATS = [const sys = S.sys = colSys(p);const V = sys.space;V.sway(5, 13);- tw(sys.E, { o: .3 }, .3, .5);+ const eqB = [0, 1, 2].flatMap(i => sys.num(`b${i}`).filter(e => !inCF(sys, e)));+ eqB.forEach(e => { tw(e, { o: 0 }, m('ex') - .2, .3); tw(e, { o: 1 }, m('b'), .5); tw(e, { o: 0 }, m('ex2') - .3, .3); tw(e, { o: 1 }, m('b2'), .5); });sys.to({ x0: 1, x1: 1, x2: 1 }, m('ex'), .6);[0, 1, 2].forEach(j => flash(sys, `x${j}`, m('ex') + .2));hide(sys.bArrow.e, m('ex') - .2, .3); hide(sys.tipLabels[3], m('ex') - .2, .3); hide(sys.mixB, m('ex') - .2, .3);@@ -297,7 +298,7 @@ const BEATS = [const sys = S.sys = colSys(p);const V = sys.space;V.sway(5, 13);- tw(sys.mixG[0], { o: 0 }, 0, 0); tw(sys.mixG[1], { o: 0 }, 0, 0); tw(sys.mixG[2], { o: 0 }, 0, 0);+ mixLetters(sys, m('mix') + .2);sys.combo.forEach(a => tw(a.e, { o: 0 }, 0, 0));sys.to({ b0: 2, b1: -2, b2: 4 }, m('b'), 1.4);[0, 1, 2].forEach(i => flash(sys, `b${i}`, m('b') + .3));@@ -308,9 +309,9 @@ const BEATS = [box(p, cfColX(0) - 8, CF_Y - 36, 82, 48, S3_COLS[0], m('try') + 4, m('add')); // the top 2 of column 1say(w, ['col 1 + col 3 = (2 + 0, −1 − 1, 0 + 4)'], 90, 705, m('add'), { size: 30 });say(w, ['= (2, −2, 4) ✓'], 90, 755, m('got'), { size: 30, fill: COL.good });- legs(sys, [1, 0, 1], [m('got') - .2, m('got') + .4, m('got') + 1]);- [0, 1, 2].forEach(j => { show(sys.mixG[j], m('mix') + .2 * j, .4); flash(sys, `x${j}`, m('mix') + .6 + .2 * j); });- sys.view('row', m('row'), .6);+ const lg = G(V.content, {}); legs(sys, [1, 0, 1], [m('got') - .2, m('got') + .4, m('got') + 1], lg); hide(lg, m('row'), .4); // the leg ends belong to the column picture+ [0, 1, 2].forEach(j => flash(sys, `x${j}`, m('mix') + .6 + .2 * j));+ sys.view('row', m('row'), .6); V.turn(ROWV3, m('row'), 1.6);show(sys.meet.e, m('row'), .3); pulse(sys.meet.e, m('row') + .8);V.turn({ yaw: VIEW.yaw + 20, pitch: 26 }, m('add'), 3);}],@@ -323,7 +324,7 @@ const BEATS = [V.sway(5, 13);sys.view('row', m('newb') - .2, .5);tw(sys.meet.e, { o: 0 }, 0, 0);- [0, 1, 2].forEach(j => tw(sys.mixG[j], { o: 0 }, m('newb') - .3, .3));+ const lt = mixLetters(sys, m('mix')); [0, 1, 2].forEach(j => { put(lt[j], { o: 0 }); show(lt[j], m('newb') - .3, .3); show(sys.num(`x${j}`)[0], 0, 0); hide(sys.num(`x${j}`)[0], m('newb') - .3, .3); });sys.to({ b0: 1, b1: 1, b2: -3 }, m('row'), 2.6);[0, 1, 2].forEach(i => flash(sys, `b${i}`, m('newb') + .4));sys.combo.forEach(a => tw(a.e, { o: 0 }, m('newb') - .3, .3));@@ -331,12 +332,12 @@ const BEATS = [const w = G(p, {});say(w, ['col 1 + col 2 = (2 − 1, −1 + 2, 0 − 3)'], 90, 650, m('c12'), { size: 30 });say(w, ['= (1, 1, −3) = b ✓'], 90, 700, m('eq'), { size: 30, fill: COL.good });- [0, 1, 2].forEach(j => { show(sys.mixG[j], m('mix') + .2 * j, .4); flash(sys, `x${j}`, m('mix') + .5 + .2 * j); });- legs(sys, [1, 1, 0], [m('path'), m('path') + .7, m('path') + 1.4]);+ [0, 1, 2].forEach(j => flash(sys, `x${j}`, m('mix') + .5 + .2 * j));+ const lg = G(V.content, {}); legs(sys, [1, 1, 0], [m('path'), m('path') + .7, m('path') + 1.4], lg); hide(lg, m('back'), .4);sys.view('row', m('back'), .6);show(sys.meet.e, m('back') + .3, .3); pulse(sys.meet.e, m('back') + .8);text(p, 'planes meet at (1, 1, 0) · mix 1, 1, 0', 90, 750, m('agree'), { size: 30, fill: COL.task, weight: 600 });- V.turn({ yaw: VIEW.yaw + 20, pitch: 26 }, m('row'), 3); V.turn({ yaw: VIEW.yaw, pitch: VIEW.pitch }, m('col'), 2);+ V.turn(ROWV3, m('newb'), 2); V.turn(VIEW, m('col'), 2); V.turn(ROWV3, m('back'), 1.6);}],['matrix', 'A x is the column picture', (m) => {@@ -441,6 +442,14 @@ const BEATS = [return t;},}], done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ S.sys = colSys(p, { mix: [90, 410] }); // the column form a little higher, so the card fits under it+ S.sys.space.sway(5, 16);+ const hint = text(p, 'try: land b on the floor, or make two columns the same', 840, 860, m('go'), { size: 26, fill: COL.dim });+ hide(hint, m('go') + 8, .6);+ }, { ask: playAsk(() => S.sys, { pos: { x: 40, y: 560, w: 720, cls: 'side' }, tip: 'Your columns. Change the mix or any number, drag an arrow tip, turn the space, or draw on the board. Nothing is marked.' }) }],['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));diff --git a/site/linear-algebra/lib/space3.js b/site/linear-algebra/lib/space3.jsindex 1d8b4b4..cab9334 100644--- a/site/linear-algebra/lib/space3.js+++ b/site/linear-algebra/lib/space3.js@@ -86,6 +86,31 @@ function S3_clipSeg(a, b, R) {return hi - lo > 1e-9 ? [a.map((x, j) => x + (b[j] - x) * lo), a.map((x, j) => x + (b[j] - x) * hi)] : null;}+// Labels that place themselves. S3_hitSeg: does the segment [[x0, y0], [x1, y1]] touch the box [x0, y0, x1, y1]?+function S3_hitSeg(r, [[x0, y0], [x1, y1]]) {+ let lo = 0, hi = 1;+ const dx = x1 - x0, dy = y1 - y0;+ for (const [p, q] of [[-dx, x0 - r[0]], [dx, r[2] - x0], [-dy, y0 - r[1]], [dy, r[3] - y0]]) {+ if (p === 0) { if (q < 0) return false; continue; }+ const t = q / p;+ if (p < 0) { if (t > hi) return false; lo = Math.max(lo, t); } else { if (t < lo) return false; hi = Math.min(hi, t); }+ }+ return true;+}+// Of the candidate boxes, the index of the one that covers the obstacles least (boxes by overlapping area, segments+// such as the axes by crossing), the earliest on a tie; bounds [x0, y0, x1, y1]: what falls outside counts too.+function S3_pick(cands, boxes, segs = [], bounds = null) {+ let best = 0, low = Infinity;+ cands.forEach((r, k) => {+ let s = k * 4;+ for (const o of boxes) { const w = Math.min(r[2], o[2]) - Math.max(r[0], o[0]), h = Math.min(r[3], o[3]) - Math.max(r[1], o[1]); if (w > 0 && h > 0) s += w * h; }+ for (const g of segs) if (S3_hitSeg(r, g)) s += 160;+ if (bounds) s += 40 * (Math.max(0, bounds[0] - r[0]) + Math.max(0, r[2] - bounds[2]) + Math.max(0, bounds[1] - r[1]) + Math.max(0, r[3] - bounds[3]));+ if (s < low) { low = s; best = k; }+ });+ return best;+}+function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, pitch = 22, t0 = .1 } = {}) {const g = G(p, { o: 0 }), svg = $('stage'), k = size / (3.4 * R), dist = S3_DIST * R;const cam = { yaw, pitch }, user = { yaw: 0, pitch: 0 }, drifts = [], items = [], sorted = [], hooks = [], avoids = [], planeItems = [];@@ -160,7 +185,10 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, pconst q = A.at(R + 1.1), L = Math.hypot(...[0, 1].map(j => A.at(R)[j] - A.at(-R)[j])) / (2 * R);return { x: q[0], y: q[1], o: L < 9 ? 0 : 1 }; // an axis pointing straight at the reader has no room for its name});- const keep = [...lab.filter(l => l.o).map(l => [l.x, l.y - 11]), ...avoids.flatMap(f => f(proj) || [])];+ const avoidPts = avoids.flatMap(f => f(proj) || []);+ const placed = placeLabels(proj, lab, avoidPts);+ const keep = [...lab.filter(l => l.o).map(l => [l.x, l.y - 11]), ...avoidPts,+ ...placed.flatMap(b => { const ks = [], y = (b[1] + b[3]) / 2; for (let x = b[0] + 10; x < b[2]; x += 28) ks.push([x, y]); return ks; })];axes.forEach((A, i) => {const P = A.at(-R), B = A.at(R + .7), L = Math.hypot(B[0] - P[0], B[1] - P[1]) || 1;let nx = (P[1] - B[1]) / L, ny = (B[0] - P[0]) / L; // the side of the axis below it, or left of an upright one@@ -177,8 +205,35 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, p});});+ // Point labels without dx/dy place themselves each redraw: of six spots round the dot (above right first), the one+ // that covers least of the axes, their names, the other dots and labels and the arrow-tip labels (avoid), and stays+ // inside the view. Returns every visible label's box, so tick numbers can step aside.+ const pts = [];+ const seen = e => { for (let n = e; n && n !== g; n = n.parentNode) if (n._st && n._st.o < .05) return false; return true; };+ function placeLabels(proj, lab, avoidPts) {+ // a dot just given a position is still hidden until its own redraw below: it counts as shown+ const vis = pts.filter(it => it.pos && (it.hid || st(it.e).o >= .05) && seen(it.e.parentNode)), out = [];+ const named = it => it.t.textContent.trim() && st(it.t).o >= .05;+ const segs = axes.filter(A => seen(A.g)).map(A => [A.at(-R), A.at(R + .7)]);+ const boxes = [...lab.filter(l => l.o).map(l => [l.x - 13, l.y - 15, l.x + 13, l.y + 14]),+ ...avoidPts.map(([x, y]) => [x - 30, y - 12, x + 30, y + 10]),+ ...vis.map(it => { const q = proj(it.pos); return [q[0] - it.r - 2, q[1] - it.r - 2, q[0] + it.r + 2, q[1] + it.r + 2]; })];+ const bounds = [cx - size / 2 - 60, cy - 420, cx + size / 2 + 60, cy + 420];+ const boxAt = (it, q, [ox, oy]) => { const w = it.t.textContent.length * it.ls * .5; return [q[0] + ox, q[1] + oy - it.ls * .78, q[0] + ox + w, q[1] + oy + it.ls * .22]; };+ vis.filter(it => !it.auto && named(it)).forEach(it => { const b = boxAt(it, proj(it.pos), it.off); boxes.push(b); out.push(b); });+ vis.filter(it => it.auto && named(it)).forEach(it => {+ const q = proj(it.pos), r = it.r, ls = it.ls, w = it.t.textContent.length * ls * .5;+ const offs = [[r + 6, -r - 4], [r + 6, r + ls * .8], [-r - 6 - w, -r - 4], [-r - 6 - w, r + ls * .8], [-w / 2, -r - 8], [-w / 2, r + ls * .85 + 2]];+ const cands = offs.map(o => boxAt(it, q, o)), k = S3_pick(cands, boxes, segs, bounds);+ it.off = offs[k];+ boxes.push(cands[k]); out.push(cands[k]);+ });+ return out;+ }+/* ---------- things in space: they re-project with the camera; set() moves them ---------- */// A dot with a label; stem: true adds its shadow on the floor and a dashed line down to it, so its height reads.+ // Without dx/dy the label finds a free spot round the dot by itself.function point(pos, { color = COL.chalk, r = 10, label = '', size: ls = 28, into = content, stem = false, dx, dy } = {}) {const e = G(into, {});const st_ = stem ? path(into, '', { stroke: color, 'stroke-width': 2, 'stroke-dasharray': '5 6', 'stroke-opacity': .7, fill: 'none' }) : null;@@ -186,8 +241,11 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, pif (st_) into.insertBefore(st_, e), into.insertBefore(sh, e);mk('circle', { r, fill: color, stroke: COL.board, 'stroke-width': 3 }, e);const t = T(e, label, { x: dx ?? r + 8, y: dy ?? -r - 6, size: ls, fill: color, font: MATH, weight: 600 });- const it = { e, pos, t, stemEl: st_, set(q) { it.pos = q; dirty(); }, label(s) { if (t.textContent !== s) t.textContent = s; } };+ const it = { e, pos, t, stemEl: st_, set(q) { it.pos = q; dirty(); }, label(s) { if (t.textContent !== s) { t.textContent = s; dirty(); } } };+ Object.assign(it, { r, ls, auto: dx === undefined && dy === undefined, off: [dx ?? r + 8, dy ?? -r - 6] });+ pts.push(it);items.push(() => {+ if (it.auto) { const s = st(t), ox = n1(it.off[0]), oy = n1(it.off[1]); if (s.x !== ox || s.y !== oy) put(t, { x: ox, y: oy }); }// hidden while pos is null; otherwise its opacity is the beat's to tweenconst q = it.pos && proj(it.pos);if (!q) { if (!it.hid) { it.hid = 1; put(e, { o: 0 }); } } else { put(e, { x: n1(q[0]), y: n1(q[1]), ...(it.hid ? { o: 1 } : {}) }); it.hid = 0; }@@ -317,6 +375,7 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, porbit.addEventListener('pointerup', end);orbit.addEventListener('lostpointercapture', end);orbit.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); e.currentTarget.blur(); P.keys?.(e); return; } // Enter checks (or goes on), as in an answer boxif (!live) return;const d = { ArrowLeft: [-10, 0], ArrowRight: [10, 0], ArrowUp: [0, 8], ArrowDown: [0, -8] }[e.key];if (!d) return;@@ -436,6 +495,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqbox.addEventListener('pointerup', end);box.addEventListener('lostpointercapture', end);box.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); e.currentTarget.blur(); P.keys?.(e); return; } // Enter checks (or goes on), as in an answer boxif (!live || s.locked) return;const d = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1 }[e.key];if (!d) return;@@ -496,7 +556,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqconst bracket = (g, x, w) => path(g, `M${x + 12} ${top}H${x}V${bot}H${x + 12}M${x + w - 12} ${top}H${x + w}V${bot}H${x + w - 12}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });let x = fx_;I.forEach(j => {- if (j) { T(CF, '+', { x: x + 16, y: fy + rh + 12, size: ms, fill: COL.chalk, font: MATH, anchor: 'middle' }); x += 38; }+ if (j) { T(CF, '+', { x: x + 26, y: fy + rh + 12, size: ms, fill: COL.chalk, font: MATH, anchor: 'middle' }); x += 38; }mixG[j] = G(CF, {});slot(mixG[j], `x${j}`, x + 56, fy + rh + 12, { anchor: 'end', fill: COL.chalk, w: 62, fs: ms });colG[j] = G(CF, {});@@ -504,9 +564,9 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqI.forEach(i => slot(colG[j], `a${i}${j}`, x + 64 + cw / 2, fy + rh * i, { anchor: 'middle', fill: S3_COLS[j], w: 56, fs: ms }));x += 64 + cw + 6;});- T(CF, '=', { x: x + 18, y: fy + rh + 12, size: ms, fill: COL.chalk, font: MATH, anchor: 'middle' });- bracket(cfB, x + 42, 84);- I.forEach(i => slot(cfB, `b${i}`, x + 84, fy + rh * i, { anchor: 'middle', fill: S3_B, w: 72, fs: ms }));+ T(CF, '=', { x: x + 23, y: fy + rh + 12, size: ms, fill: COL.chalk, font: MATH, anchor: 'middle' });+ bracket(cfB, x + 52, 84);+ I.forEach(i => slot(cfB, `b${i}`, x + 94, fy + rh * i, { anchor: 'middle', fill: S3_B, w: 72, fs: ms }));}/* ---------- the space: rows as planes, columns as arrows ---------- */@@ -542,20 +602,33 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqreturn { g, ring, k };});const tipLabels = tipKeys.map((k, n) => T(COLV, '', { size: 28, fill: tipColor[n], font: MATH, weight: 600 }));- // beside the tip, a column's on the arrow's right-hand side and b's on its left (b often lies along a column);+ // beside the tip, a column's on the arrow's right-hand side and b's on its left (b often lies along a column), unless+ // that side covers an axis, an axis name, another arrow or an earlier label and the other side does not;// past the tip is where a dashed mix often runs on- const labelAt = (n, proj) => {- const O = proj([0, 0, 0]), q = proj(tipOf(tipKeys[n])), L = Math.hypot(q[0] - O[0], q[1] - O[1]) || 1, ux = (q[0] - O[0]) / L, uy = (q[1] - O[1]) / L;- const side = tipKeys[n] === 'b' ? -1 : 1, nx = -uy * side, ny = ux * side;- return { q, x: Math.round(q[0] + ux * 14 + nx * 20), y: Math.round(q[1] + uy * 14 + ny * 24 + 9), anchor: nx > .35 ? 'start' : nx < -.35 ? 'end' : 'middle' };+ const tipPlace = proj => {+ const O = proj([0, 0, 0]), ends = tipKeys.map(k => proj(tipOf(k)));+ const segs = I.map(j => { const a = [0, 0, 0], b = [0, 0, 0]; a[j] = -R; b[j] = R + .7; return [proj(a), proj(b)]; });+ const boxes = I.map(j => { const q = [0, 0, 0]; q[j] = R + 1.1; const s = proj(q); return [s[0] - 13, s[1] - 15, s[0] + 13, s[1] + 14]; });+ return tipKeys.map((k, n) => {+ const q = ends[n], L = Math.hypot(q[0] - O[0], q[1] - O[1]) || 1, ux = (q[0] - O[0]) / L, uy = (q[1] - O[1]) / L, w = tipLabels[n].textContent.length * 14;+ const cand = [k === 'b' ? -1 : 1, k === 'b' ? 1 : -1].map(side => {+ const nx = -uy * side, ny = ux * side, x = Math.round(q[0] + ux * 14 + nx * 20), y = Math.round(q[1] + uy * 14 + ny * 24 + 9);+ const anchor = nx > .35 ? 'start' : nx < -.35 ? 'end' : 'middle', x0 = anchor === 'start' ? x : anchor === 'end' ? x - w : x - w / 2;+ return { q, x, y, anchor, box: [x0, y - 22, x0 + w, y + 6] };+ });+ const c = cand[S3_pick(cand.map(c => c.box), boxes, [...segs, ...ends.filter((_, m) => m !== n).map(e => [O, e])])];+ if (tipLabels[n].textContent) boxes.push(c.box);+ return c;+ });};- V.avoid(proj => st(COLV).o > .05 ? tipLabels.flatMap((t, n) => t.textContent ? [[labelAt(n, proj).x, labelAt(n, proj).y - 9]] : []) : []);+ V.avoid(proj => { if (st(COLV).o <= .05) return []; const P = tipPlace(proj); return tipLabels.flatMap((t, n) => t.textContent ? [[P[n].x, P[n].y - 9]] : []); });V.on(proj => {planes.forEach((pl, i) => { const d = pl.e.getAttribute('d'); if (hits[i].getAttribute('d') !== d) hits[i].setAttribute('d', d); });// a meeting line is as bright as the dimmer of its two planes[[0, 1], [0, 2], [1, 2]].forEach(([i, j], n) => { const o = String(Math.round(.75 * Math.min(planes[i].k, planes[j].k) * 100) / 100); if (lines[n].e.getAttribute('stroke-opacity') !== o) lines[n].e.setAttribute('stroke-opacity', o); });+ const P = tipPlace(proj);tips.forEach(({ g }, n) => {- const L = labelAt(n, proj), t = tipLabels[n];+ const L = P[n], t = tipLabels[n];put(g, { x: Math.round(L.q[0] * 10) / 10, y: Math.round(L.q[1] * 10) / 10 });if (t.getAttribute('text-anchor') !== L.anchor) t.setAttribute('text-anchor', L.anchor);put(t, { x: L.x, y: L.y });@@ -611,6 +684,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqputTip(k, q);}, () => guide.set(null, null)));tips.forEach(({ g, k }) => g.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); e.currentTarget.blur(); P.keys?.(e); return; } // Enter checks (or goes on), as in an answer boxif (!live || !free(tipKeysOf(k))) return;const up = e.key === 'ArrowUp' || e.key === 'PageUp' ? 1 : e.key === 'ArrowDown' || e.key === 'PageDown' ? -1 : 0;const j = e.key === 'ArrowLeft' || e.key === 'ArrowRight' ? 0 : up && (e.shiftKey || e.key.startsWith('Page')) ? 1 : up ? 2 : -1;