Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(linear-algebra): chapters 8-10 and grid2.js, the plane a matrix moves

yzr9310a82bf816
diff --git a/site/linear-algebra/ch08/audio/en/play.mp3 b/site/linear-algebra/ch08/audio/en/play.mp3
new file mode 100644
index 0000000..205bfd9
Binary files /dev/null and b/site/linear-algebra/ch08/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch08/audio/en/timings.js b/site/linear-algebra/ch08/audio/en/timings.js
index e1f8cf8..e837837 100644
--- a/site/linear-algebra/ch08/audio/en/timings.js
+++ b/site/linear-algebra/ch08/audio/en/timings.js
@@ -748,6 +748,30 @@ window.TIMINGS = {
]
]
},
+ "play": {
+ "dur": 16.368,
+ "marks": {
+ "go": 4.01
+ },
+ "cues": [
+ [
+ 0.104,
+ "Playground."
+ ],
+ [
+ 1.081,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 4.01,
+ "Change any number, in the matrix or in the equations, drag the lines or the arrows, draw on the board if you like, and watch both places change together."
+ ],
+ [
+ 14.675,
+ "Press continue when you're done."
+ ]
+ ]
+ },
"finish": {
"dur": 10.176,
"marks": {},
diff --git a/site/linear-algebra/ch08/index.html b/site/linear-algebra/ch08/index.html
index d6f8463..e47eed9 100644
--- a/site/linear-algebra/ch08/index.html
+++ b/site/linear-algebra/ch08/index.html
@@ -11,6 +11,7 @@
<script src="../lib/engine.js"></script>
<script src="../lib/math.js"></script>
<script src="../lib/linsys.js"></script>
+<script src="../lib/play.js"></script>
<script src="audio/en/timings.js"></script>
<script>
'use strict';
@@ -46,6 +47,7 @@ const termBox = (sys, key) => {
// Rounded frames around both copies of a number; redrawn while shown, so they follow a number that changes width.
function rings(sys, key, into, t0, t1, { tag = true } = {}) {
const g = G(into, { o: 0 }), c = keyColor(key);
+ g.style.pointerEvents = 'none'; // a frame never takes the pointer from the number under it
const r1 = mk('rect', { rx: 12, fill: c, 'fill-opacity': .14, stroke: c, 'stroke-width': 3 }, g);
const r2 = mk('rect', { rx: 12, fill: c, 'fill-opacity': .14, stroke: c, 'stroke-width': 3 }, g);
const lab = tag ? T(g, where(key), { size: 24, fill: c, weight: 600, anchor: 'middle' }) : null;
@@ -625,6 +627,14 @@ const BEATS = [
'Leave every other number as it was. (1, 1) must solve the first equation: 1 + (row 1, column 2)·1 = 3.', () => S.sys.set({ a01: 2 }))),
}], done, 'Chapter practice · set 4 of 4');
} }],
+ ['play', 'Playground', (m, D) => {
+ const p = panel(0);
+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });
+ S.sys = sysOf(p, [[2, -1], [-1, 2]], [0, 3], { view: 'both', plane: { cx: 1180, cy: 590, u: 36 } }); // a smaller plane under the card
+ S.sys.labels(['col 1', 'col 2', 'b']);
+ const hint = text(p, 'try: row 2 = 2 × row 1 · a 0 in row 1, column 2 · meet at (2, 1)', 400, 700, m('go'), { size: 24, fill: COL.dim, anchor: 'middle' });
+ hide(hint, Math.min(m('go') + 9, D - .7), .6);
+ }, { ask: playAsk(() => S.sys, { pos: { x: 800, y: 24, w: 776, cls: 'side' }, tip: 'Change any number, in A or in the equations, drag a line or an arrow, or draw. Nothing is marked.' }) }],
['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
diff --git a/site/linear-algebra/ch09/audio/en/play.mp3 b/site/linear-algebra/ch09/audio/en/play.mp3
new file mode 100644
index 0000000..59621be
Binary files /dev/null and b/site/linear-algebra/ch09/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch09/audio/en/timings.js b/site/linear-algebra/ch09/audio/en/timings.js
index 59e47a9..d400a8e 100644
--- a/site/linear-algebra/ch09/audio/en/timings.js
+++ b/site/linear-algebra/ch09/audio/en/timings.js
@@ -700,6 +700,30 @@ window.TIMINGS = {
]
]
},
+ "play": {
+ "dur": 12.984,
+ "marks": {
+ "go": 4.036
+ },
+ "cues": [
+ [
+ 0.091,
+ "Playground."
+ ],
+ [
+ 1.055,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 4.036,
+ "Change A or x, drag the point x or the columns, and watch A x follow, one column step at a time."
+ ],
+ [
+ 11.263,
+ "Press continue when you're done."
+ ]
+ ]
+ },
"finish": {
"dur": 9.432,
"marks": {},
diff --git a/site/linear-algebra/ch09/index.html b/site/linear-algebra/ch09/index.html
index 7e56cae..04f93ae 100644
--- a/site/linear-algebra/ch09/index.html
+++ b/site/linear-algebra/ch09/index.html
@@ -12,6 +12,7 @@
<script src="../lib/math.js"></script>
<script src="../lib/linsys.js"></script>
<script src="../lib/grid2.js"></script>
+<script src="../lib/play.js"></script>
<script src="audio/en/timings.js"></script>
<script>
'use strict';
@@ -105,7 +106,7 @@ const xBand = (p, g, t0, t1) => band(p, g.lay.x - 40, DISP[1] - 52, 80, 140, COL
const target = (P2, [x, y], into, t0 = .3) => {
const g = G(into, { x: P2.PX(x), y: P2.PY(y), o: 0 });
mk('circle', { r: 17, fill: 'none', stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);
- T(g, `target (${num(x)}, ${num(y)})`, { x: 22, y: -18, size: 22, fill: COL.task, font: MATH });
+ T(g, `target (${num(x)}, ${num(y)})`, { x: 20, y: 40, size: 22, fill: COL.task, font: MATH });
show(g, t0, .4);
return g;
};
@@ -119,7 +120,7 @@ function matEl(rows, { size = 30, fill = null } = {}) {
rows.forEach((r, i) => r.forEach((v, j) => T(svg, num(v), { x: 8 + cw * (j + .5), y: rh * (i + .5) + size * .5, size, fill: fill || COLC[j], font: MATH, anchor: 'middle' })));
return svg;
}
-const prodEl = (A, x) => { const s = h('span', '', [$m('A'), ' = ', matEl(A), ' ', $m('x'), ' = ', matEl(x.map(v => [v]), { fill: 'currentColor' })]); s.style.whiteSpace = 'pre'; return s; };
+const prodEl = (A, x) => { const s = h('span', '', [rich([$m('A'), ' = ']), matEl(A), ' ', rich([$m('x'), ' = ']), matEl(x.map(v => [v]), { fill: 'currentColor' })]); s.style.whiteSpace = 'pre'; return s; };
/* ---------- practice data ---------- */
const COLQ = [
@@ -560,6 +561,14 @@ const BEATS = [
'x = (0, 2) means 0 of column 1 plus 2 of column 2. So 2 · column 2 = (−2, 4).', () => S.g.set({ a01: -1, a11: 2 }), ['A', 'cols'])),
}], done, 'Chapter practice · set 4 of 4');
} }],
+ ['play', 'Playground', (m, D) => {
+ const p = panel(0);
+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });
+ S.sys = g2Of(p, [[2, 1], [1, 3]], [1, 1]);
+ S.sys.labels(['col 1', 'col 2']);
+ const hint = text(p, 'try: x = (1, 0) gives column 1 · x = (0, 1) gives column 2 · a negative number in x', 1160, 860, m('go'), { size: 24, fill: COL.dim, anchor: 'middle' });
+ hide(hint, Math.min(m('go') + 9, D - .7), .6);
+ }, { ask: playAsk(() => S.sys, { tip: 'A times x, live. Change A or x, drag the point x or a column tip, 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/ch10/audio/en/basis.mp3 b/site/linear-algebra/ch10/audio/en/basis.mp3
new file mode 100644
index 0000000..c211770
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/basis.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/count.mp3 b/site/linear-algebra/ch10/audio/en/count.mp3
new file mode 100644
index 0000000..bd6ce0d
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/count.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/drag.mp3 b/site/linear-algebra/ch10/audio/en/drag.mp3
new file mode 100644
index 0000000..5162e2c
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/drag.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/final1.mp3 b/site/linear-algebra/ch10/audio/en/final1.mp3
new file mode 100644
index 0000000..e3bf78d
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/final1.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/final2.mp3 b/site/linear-algebra/ch10/audio/en/final2.mp3
new file mode 100644
index 0000000..8211e30
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/final2.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/final3.mp3 b/site/linear-algebra/ch10/audio/en/final3.mp3
new file mode 100644
index 0000000..595772e
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/final3.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/final4.mp3 b/site/linear-algebra/ch10/audio/en/final4.mp3
new file mode 100644
index 0000000..468da7d
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/final4.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/finish.mp3 b/site/linear-algebra/ch10/audio/en/finish.mp3
new file mode 100644
index 0000000..c5be5bb
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/finish.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/flip.mp3 b/site/linear-algebra/ch10/audio/en/flip.mp3
new file mode 100644
index 0000000..a71037f
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/flip.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/grid.mp3 b/site/linear-algebra/ch10/audio/en/grid.mp3
new file mode 100644
index 0000000..b9c286b
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/grid.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/intro.mp3 b/site/linear-algebra/ch10/audio/en/intro.mp3
new file mode 100644
index 0000000..952bbc0
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/intro.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/one.mp3 b/site/linear-algebra/ch10/audio/en/one.mp3
new file mode 100644
index 0000000..a4fece8
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/one.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/play.mp3 b/site/linear-algebra/ch10/audio/en/play.mp3
new file mode 100644
index 0000000..f569da1
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/q1.mp3 b/site/linear-algebra/ch10/audio/en/q1.mp3
new file mode 100644
index 0000000..f3efc1a
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/q1.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/q2.mp3 b/site/linear-algebra/ch10/audio/en/q2.mp3
new file mode 100644
index 0000000..420a892
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/q2.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/q3.mp3 b/site/linear-algebra/ch10/audio/en/q3.mp3
new file mode 100644
index 0000000..9394d80
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/q3.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/shear.mp3 b/site/linear-algebra/ch10/audio/en/shear.mp3
new file mode 100644
index 0000000..0c3304c
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/shear.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/solve.mp3 b/site/linear-algebra/ch10/audio/en/solve.mp3
new file mode 100644
index 0000000..33191cf
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/solve.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/squash.mp3 b/site/linear-algebra/ch10/audio/en/squash.mp3
new file mode 100644
index 0000000..8e1f1fd
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/squash.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/stretch.mp3 b/site/linear-algebra/ch10/audio/en/stretch.mp3
new file mode 100644
index 0000000..7deb425
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/stretch.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/timings.js b/site/linear-algebra/ch10/audio/en/timings.js
new file mode 100644
index 0000000..1d4177e
--- /dev/null
+++ b/site/linear-algebra/ch10/audio/en/timings.js
@@ -0,0 +1,764 @@
+window.TIMINGS = {
+ "intro": {
+ "dur": 13.608,
+ "marks": {
+ "sub": 3.607,
+ "move": 8.19
+ },
+ "cues": [
+ [
+ 0.104,
+ "Chapter ten."
+ ],
+ [
+ 1.224,
+ "A matrix moves the whole plane."
+ ],
+ [
+ 3.607,
+ "In chapter nine, A times one vector x gave one new vector."
+ ],
+ [
+ 8.19,
+ "Now we let A act on every point of the plane at once, and watch the whole grid move."
+ ]
+ ]
+ },
+ "one": {
+ "dur": 42.936,
+ "marks": {
+ "A": 1.51,
+ "x": 6.602,
+ "rows": 9.505,
+ "land": 14.792,
+ "x2": 18.372,
+ "land2": 24.896,
+ "many": 27.135,
+ "go": 32.539,
+ "check": 36.797
+ },
+ "cues": [
+ [
+ 0.117,
+ "Here's a matrix: A is two, minus one in the first row, and one, one in the second."
+ ],
+ [
+ 6.602,
+ "Take the point x equals one, one."
+ ],
+ [
+ 9.505,
+ "By rows: two times one, minus one, is one."
+ ],
+ [
+ 13.138,
+ "One plus one is two."
+ ],
+ [
+ 14.792,
+ "So A sends the point one, one to the point one, two."
+ ],
+ [
+ 18.372,
+ "Another point: two, zero."
+ ],
+ [
+ 20.807,
+ "Two times two is four, and two plus zero is two."
+ ],
+ [
+ 24.896,
+ "Two, zero goes to four, two."
+ ],
+ [
+ 27.135,
+ "Now do that for many points at once."
+ ],
+ [
+ 29.57,
+ "Every dot moves to the place A sends it."
+ ],
+ [
+ 32.539,
+ "Watch."
+ ],
+ [
+ 33.372,
+ "Each dot slides from where it was to where A sends it."
+ ],
+ [
+ 36.797,
+ "One, one ends up at one, two, and two, zero at four, two, just as we worked out."
+ ]
+ ]
+ },
+ "grid": {
+ "dur": 24.864,
+ "marks": {
+ "go": 3.438,
+ "straight": 7.044,
+ "par": 9.766,
+ "faint": 14.714,
+ "sq": 18.802
+ },
+ "cues": [
+ [
+ 0.091,
+ "Not just the dots: the lines of the grid move too."
+ ],
+ [
+ 3.438,
+ "Here's the plain grid, and here is A acting on it."
+ ],
+ [
+ 7.044,
+ "Every straight line lands on a straight line."
+ ],
+ [
+ 9.766,
+ "Lines that were parallel stay parallel, and the steps between them stay equal."
+ ],
+ [
+ 14.714,
+ "The old grid stays faint behind, so you can compare."
+ ],
+ [
+ 18.802,
+ "And the little square between zero, zero and one, one becomes a slanted box."
+ ]
+ ]
+ },
+ "basis": {
+ "dur": 49.824,
+ "marks": {
+ "e1": 1.562,
+ "c1": 9.102,
+ "e2": 11.25,
+ "why": 15.703,
+ "all": 23.216,
+ "grid": 33.438,
+ "read": 39.831
+ },
+ "cues": [
+ [
+ 0.091,
+ "Now the key idea."
+ ],
+ [
+ 1.562,
+ "Where does the point one, zero go?"
+ ],
+ [
+ 4.036,
+ "Two times one is two, one times one is one: it lands on two, one."
+ ],
+ [
+ 9.102,
+ "That's exactly column one of A."
+ ],
+ [
+ 11.25,
+ "And zero, one?"
+ ],
+ [
+ 12.669,
+ "Minus one, and one: column two."
+ ],
+ [
+ 15.703,
+ "That's no accident."
+ ],
+ [
+ 17.018,
+ "By columns, A times one, zero is one of column one, plus nothing of column two."
+ ],
+ [
+ 23.216,
+ "Any other point x, y is x steps of one, zero and y steps of zero, one."
+ ],
+ [
+ 29.336,
+ "So it lands on x steps of column one and y steps of column two."
+ ],
+ [
+ 33.438,
+ "That's what the moved grid is: steps of the green column one way, steps of the violet column the other way."
+ ],
+ [
+ 39.831,
+ "So you can read a matrix straight off the picture: column one is where one, zero lands."
+ ],
+ [
+ 46.107,
+ "Column two is where zero, one lands."
+ ]
+ ]
+ },
+ "count": {
+ "dur": 45.696,
+ "marks": {
+ "q": 1.146,
+ "s1": 2.656,
+ "s2": 7.083,
+ "land": 11.172,
+ "grid": 17.148,
+ "rows": 22.539,
+ "q2": 29.297,
+ "t1": 31.615,
+ "t2": 35.951,
+ "land2": 39.336,
+ "back": 41.602
+ },
+ "cues": [
+ [
+ 0.104,
+ "Let's use it."
+ ],
+ [
+ 1.146,
+ "Where does two, one go?"
+ ],
+ [
+ 2.656,
+ "Two steps of column one: two times two, one is four, two."
+ ],
+ [
+ 7.083,
+ "Then one step of column two: plus minus one, one."
+ ],
+ [
+ 11.172,
+ "Four minus one is three, two plus one is three: it lands on three, three."
+ ],
+ [
+ 17.148,
+ "On the moved grid, you can count it: two green steps, then one violet step."
+ ],
+ [
+ 22.539,
+ "Check by rows: two times two, minus one, is three, and two plus one is three."
+ ],
+ [
+ 29.297,
+ "One more: minus one, two."
+ ],
+ [
+ 31.615,
+ "Minus one step of column one is minus two, minus one."
+ ],
+ [
+ 35.951,
+ "Two steps of column two is minus two, two."
+ ],
+ [
+ 39.336,
+ "Together: minus four, one."
+ ],
+ [
+ 41.602,
+ "One green step backwards, two violet steps forwards."
+ ]
+ ]
+ },
+ "drag": {
+ "dur": 33.576,
+ "marks": {
+ "grab": 4.362,
+ "c1": 6.393,
+ "c1n": 9.01,
+ "grab2": 14.388,
+ "c2": 15.625,
+ "c2n": 17.148,
+ "scrub": 22.552,
+ "scrubn": 28.685,
+ "same": 30.352
+ },
+ "cues": [
+ [
+ 0.104,
+ "Which means: if you move the columns, you move the matrix."
+ ],
+ [
+ 4.362,
+ "Let's grab the tip of column one, and drag it to three, zero."
+ ],
+ [
+ 9.01,
+ "The whole grid follows, and the first column of A changes to three, zero."
+ ],
+ [
+ 14.388,
+ "Now column two: drag it to one, two."
+ ],
+ [
+ 17.148,
+ "Again the grid follows, and the second column of A becomes one, two."
+ ],
+ [
+ 22.552,
+ "It works the other way round too."
+ ],
+ [
+ 24.453,
+ "Change the number in row one, column one from three to one, and the grid moves with it."
+ ],
+ [
+ 30.352,
+ "The arrows and the numbers are one and the same thing."
+ ]
+ ]
+ },
+ "q1": {
+ "dur": 5.76,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Your turn."
+ ],
+ [
+ 1.042,
+ "Drag the two column tips onto the targets, and watch the matrix."
+ ]
+ ]
+ },
+ "stretch": {
+ "dur": 28.752,
+ "marks": {
+ "A": 2.63,
+ "c": 5.247,
+ "see": 14.479,
+ "flag": 19.609,
+ "both": 22.747
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now some matrices with a clear meaning."
+ ],
+ [
+ 2.63,
+ "Two, zero, zero, one."
+ ],
+ [
+ 5.247,
+ "Column one is two, zero: one, zero goes twice as far."
+ ],
+ [
+ 10.911,
+ "Column two is zero, one: it stays."
+ ],
+ [
+ 14.479,
+ "So the plane is stretched sideways to twice its width, and heights don't change."
+ ],
+ [
+ 19.609,
+ "Watch the little flag: it gets twice as wide."
+ ],
+ [
+ 22.747,
+ "Two, zero, zero, two stretches both ways: everything twice as big."
+ ]
+ ]
+ },
+ "flip": {
+ "dur": 16.296,
+ "marks": {
+ "A": 0.091,
+ "c": 3.073,
+ "see": 8.763,
+ "flag": 13.255
+ },
+ "cues": [
+ [
+ 0.091,
+ "Minus one, zero, zero, one."
+ ],
+ [
+ 3.073,
+ "Column one is minus one, zero: one, zero lands on the other side."
+ ],
+ [
+ 8.763,
+ "Every point goes to its mirror image across the up and down axis."
+ ],
+ [
+ 13.255,
+ "The flag now points left."
+ ],
+ [
+ 15.234,
+ "This is a flip."
+ ]
+ ]
+ },
+ "shear": {
+ "dur": 17.664,
+ "marks": {
+ "A": 0.117,
+ "c": 1.953,
+ "see": 7.018,
+ "flag": 14.805
+ },
+ "cues": [
+ [
+ 0.117,
+ "One, one, zero, one."
+ ],
+ [
+ 1.953,
+ "Column one stays at one, zero."
+ ],
+ [
+ 4.401,
+ "Column two leans over, to one, one."
+ ],
+ [
+ 7.018,
+ "The bottom line stays put, and every line above it slides sideways: the higher it is, the further it slides."
+ ],
+ [
+ 14.805,
+ "The flag leans."
+ ],
+ [
+ 16.302,
+ "This is called a shear."
+ ]
+ ]
+ },
+ "turn": {
+ "dur": 30.456,
+ "marks": {
+ "A": 0.091,
+ "c": 2.513,
+ "see": 10.573,
+ "flag": 16.562,
+ "half": 21.875
+ },
+ "cues": [
+ [
+ 0.091,
+ "Zero, minus one, one, zero."
+ ],
+ [
+ 2.513,
+ "One, zero lands on zero, one: straight up."
+ ],
+ [
+ 5.938,
+ "And zero, one lands on minus one, zero: to the left."
+ ],
+ [
+ 10.573,
+ "Both arrows have turned a quarter turn, counterclockwise, and the whole plane turns with them."
+ ],
+ [
+ 16.562,
+ "The flag stands up."
+ ],
+ [
+ 18.021,
+ "Nothing is stretched, nothing is flipped: it's a turn."
+ ],
+ [
+ 21.875,
+ "Turn twice, and you get minus one, zero, zero, minus one: a half turn."
+ ],
+ [
+ 28.62,
+ "The flag hangs upside down."
+ ]
+ ]
+ },
+ "q2": {
+ "dur": 3.216,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.094,
+ "Read the matrix off the picture."
+ ]
+ ]
+ },
+ "squash": {
+ "dur": 44.712,
+ "marks": {
+ "A": 1.862,
+ "c": 3.737,
+ "see": 12.161,
+ "lost": 16.888,
+ "miss": 25.234,
+ "zero": 37.878
+ },
+ "cues": [
+ [
+ 0.104,
+ "One more, and it's strange."
+ ],
+ [
+ 1.862,
+ "One, two, two, four."
+ ],
+ [
+ 3.737,
+ "Column one is one, two."
+ ],
+ [
+ 5.534,
+ "Column two is two, four: exactly twice column one."
+ ],
+ [
+ 10.104,
+ "Both columns point the same way."
+ ],
+ [
+ 12.161,
+ "So the whole plane gets squashed onto one line, the line through one, two."
+ ],
+ [
+ 16.888,
+ "Many points land on the same point."
+ ],
+ [
+ 19.232,
+ "Two, minus one goes to two minus two, and four minus four: zero, zero."
+ ],
+ [
+ 25.234,
+ "And a point off that line, like one, zero, can never be reached."
+ ],
+ [
+ 29.883,
+ "Can A x equal b for every b?"
+ ],
+ [
+ 33.372,
+ "For this matrix, no."
+ ],
+ [
+ 34.935,
+ "That's the big question of chapter fourteen."
+ ],
+ [
+ 37.878,
+ "And the matrix of all zeros squashes everything into one single point: the origin."
+ ]
+ ]
+ },
+ "solve": {
+ "dur": 43.32,
+ "marks": {
+ "A": 3.789,
+ "q": 11.758,
+ "try": 14.18,
+ "move": 19.935,
+ "found": 22.721,
+ "same": 28.841,
+ "other": 37.057
+ },
+ "cues": [
+ [
+ 0.104,
+ "So what does solving A x equals b mean, in this picture?"
+ ],
+ [
+ 3.789,
+ "Take the matrix of our system, two, minus one, minus one, two, and b equals zero, three."
+ ],
+ [
+ 11.758,
+ "We want the point x that A sends to b."
+ ],
+ [
+ 14.18,
+ "Try x equals two, one: it lands on three, zero."
+ ],
+ [
+ 18.997,
+ "Not there."
+ ],
+ [
+ 19.935,
+ "Move x, and A x moves with it."
+ ],
+ [
+ 22.721,
+ "At x equals one, two, A x lands exactly on zero, three."
+ ],
+ [
+ 28.841,
+ "One, two: the solution we found in chapter two."
+ ],
+ [
+ 32.643,
+ "Solving A x equals b means finding the point that A moves onto b."
+ ],
+ [
+ 37.057,
+ "And the miss wasn't wasted: x equals two, one is the answer when b is three, zero."
+ ]
+ ]
+ },
+ "q3": {
+ "dur": 2.784,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.094,
+ "Click where the point lands."
+ ]
+ ]
+ },
+ "wrap": {
+ "dur": 32.616,
+ "marks": {
+ "w1": 1.003,
+ "w2": 5.677,
+ "w3": 11.315,
+ "w4": 20.951,
+ "end": 30.69
+ },
+ "cues": [
+ [
+ 0.104,
+ "To sum up."
+ ],
+ [
+ 1.003,
+ "A matrix moves every point of the plane: the point x goes to A x."
+ ],
+ [
+ 5.677,
+ "Straight lines stay straight, parallel lines stay parallel and evenly spaced."
+ ],
+ [
+ 11.315,
+ "Column one is where one, zero lands, column two is where zero, one lands."
+ ],
+ [
+ 18.086,
+ "Move a column, and the matrix changes."
+ ],
+ [
+ 20.951,
+ "Stretch, flip, shear, turn, squash: each is a matrix."
+ ],
+ [
+ 26.536,
+ "And solving A x equals b means finding the point that lands on b."
+ ],
+ [
+ 30.69,
+ "Now try the chapter practice."
+ ]
+ ]
+ },
+ "final1": {
+ "dur": 3.288,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice."
+ ],
+ [
+ 1.536,
+ "Where does each point land?"
+ ]
+ ]
+ },
+ "final2": {
+ "dur": 2.064,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Next, what does each matrix do?"
+ ]
+ ]
+ },
+ "final3": {
+ "dur": 2.592,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Now read the matrix off the picture."
+ ]
+ ]
+ },
+ "final4": {
+ "dur": 3.096,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Last set."
+ ],
+ [
+ 1.159,
+ "Make the move with your hands."
+ ]
+ ]
+ },
+ "play": {
+ "dur": 14.184,
+ "marks": {
+ "go": 4.062
+ },
+ "cues": [
+ [
+ 0.117,
+ "Playground."
+ ],
+ [
+ 1.107,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 4.062,
+ "Drag the columns or change the numbers, and watch the whole plane move."
+ ],
+ [
+ 9.102,
+ "Try a turn, a flip or a squash of your own."
+ ],
+ [
+ 12.474,
+ "Press continue when you're done."
+ ]
+ ]
+ },
+ "finish": {
+ "dur": 10.416,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Well done."
+ ],
+ [
+ 1.12,
+ "That's the end of chapter ten, a matrix moves the whole plane."
+ ],
+ [
+ 5.391,
+ "Next: a third unknown, and a third direction."
+ ],
+ [
+ 9.414,
+ "Space."
+ ]
+ ]
+ }
+};
diff --git a/site/linear-algebra/ch10/audio/en/turn.mp3 b/site/linear-algebra/ch10/audio/en/turn.mp3
new file mode 100644
index 0000000..835a3f5
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/turn.mp3 differ
diff --git a/site/linear-algebra/ch10/audio/en/wrap.mp3 b/site/linear-algebra/ch10/audio/en/wrap.mp3
new file mode 100644
index 0000000..1683ecb
Binary files /dev/null and b/site/linear-algebra/ch10/audio/en/wrap.mp3 differ
diff --git a/site/linear-algebra/ch10/index.html b/site/linear-algebra/ch10/index.html
new file mode 100644
index 0000000..37d994c
--- /dev/null
+++ b/site/linear-algebra/ch10/index.html
@@ -0,0 +1,473 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>A Matrix Moves the Whole Plane</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../lib/math.js"></script>
+<script src="../lib/grid2.js"></script>
+<script src="../lib/play.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 10, title: 'A Matrix Moves the Whole Plane', minutes: 9, language: 'en' };
+
+/* ---------- layout and colours ---------- */
+const DISP = [90, 230]; // the matrix in brackets, top left
+const ROWC = [COL.whole, COL.nat], COLC = [COL.irr, COL.real];
+const LEFT = { x: 40, y: 420, w: 720, cls: 'side' }; // question card under the matrix; the plane stays on the right
+const TOPL = { x: 40, y: 190, w: 720, cls: 'side' }; // question card at the top left (matrix hidden)
+const A1 = [[2, -1], [1, 1]]; // the chapter's first matrix
+const I2 = [[1, 0], [0, 1]];
+
+/* ---------- chapter drawing helpers ---------- */
+const 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; };
+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
+const frame = (p, x, y, w, hh, c, t0, t1) => { const r = mk('rect', { x, y, width: w, height: hh, rx: 14, fill: 'none', stroke: c, 'stroke-width': 3 }, p); put(r, { o: 0 }); show(r, t0, .4); if (t1 !== undefined) hide(r, t1, .4); return r; };
+const band = (p, x, y, w, hh, c, t0, t1, o = .2) => { const r = mk('rect', { x, y, width: w, height: hh, rx: 14, fill: c }, p); put(r, { o: 0 }); tw(r, { o }, t0, .4); if (t1 !== undefined) tw(r, { o: 0 }, t1, .4); return r; };
+const flash = (g, key, t0) => g.num(key).forEach(e => { const c0 = e.getAttribute('fill'); tw(e, { c_fill: COL.task }, t0, .25); tw(e, { c_fill: c0 }, t0 + 1.2, .6); pulse(e, t0, 1.3); });
+const keysOf = A => ({ a00: A[0][0], a01: A[0][1], a10: A[1][0], a11: A[1][1] });
+const thick = (e, t, w = 5) => { tw(e, { 'a_stroke-width': w * 2 }, t, .3); tw(e, { 'a_stroke-width': w }, t + 1.4, .5); };
+const pair = (x, y) => `(${num(x)}, ${num(y)})`;
+// The moved plane in this chapter's layout: matrix top left, plane on the right, grid, unit square and flag on.
+const planeOf = (p, A, o = {}) => grid2(p, { A, mat: DISP, shape: true, ...o });
+// A column of the matrix in brackets, framed (j = 0, 1).
+const colFrame = (p, g, j, t0, t1) => frame(p, g.lay.A[0][j] - 42, DISP[1] - 56, 84, 150, COLC[j], t0, t1);
+// A dot carried by A: it slides from p to A·p.
+const carry = (g, p, into, t0, { color = COL.chalk, dur = 1.6, r = 8, move = t0 + .4 } = {}) => {
+ const [x, y] = p, [X, Y] = [g.v.a00 * x + g.v.a01 * y, g.v.a10 * x + g.v.a11 * y], { PX, PY } = g.P;
+ const d = G(into, { x: PX(x), y: PY(y), o: 0 });
+ mk('circle', { r, fill: color, stroke: COL.board, 'stroke-width': 2 }, d);
+ show(d, t0, .3); tw(d, { x: PX(X), y: PY(Y) }, move, dur);
+ return d;
+};
+const ring = (P2, [x, y], color, into, t0, label, { dx = 20, dy = -18, anchor = 'start' } = {}) => {
+ const g = G(into, { x: P2.PX(x), y: P2.PY(y), o: 0 });
+ mk('circle', { r: 17, fill: 'none', stroke: color, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);
+ if (label) T(g, label, { x: dx, y: dy, size: 22, fill: color, font: MATH, anchor });
+ if (t0 !== undefined) show(g, t0, .4); else put(g, { o: 1 });
+ return g;
+};
+// A pointer that drags a handle from a to b (stage px) over [tm, tm + dur], the same ease as g.to; shown t0 … t1.
+// Its place is a function of time alone, so seeking shows the same frame as playing.
+function pointer(p, a, b, tm, dur, t0, t1, ease = io) {
+ const g = G(p, { o: 0 });
+ path(g, 'M0 0L0 30L8 22L14 36L20 33L14 20L25 20Z', { fill: COL.chalk, stroke: COL.board, 'stroke-width': 2 });
+ prog(q => { const t = t0 + q * (t1 - t0), k = ease(Math.max(0, Math.min(1, (t - tm) / dur))); put(g, { x: a[0] + (b[0] - a[0]) * k + 4, y: a[1] + (b[1] - a[1]) * k + 4 }); }, t0, t1 - t0, lin);
+ show(g, t0, .3); hide(g, t1, .3);
+ return g;
+}
+// Inline matrix for a card.
+function matEl(rows, { size = 28 } = {}) {
+ const n = rows[0].length, cw = size * 1.8, rh = size * 1.3, w = cw * n + 16, hh = rh * rows.length + size * .3;
+ const svg = mk('svg', { class: 'm', viewBox: `0 0 ${w} ${hh}`, width: w, height: hh });
+ svg.style.verticalAlign = 'middle';
+ path(svg, `M12 2H3V${hh - 2}H12M${w - 12} 2H${w - 3}V${hh - 2}H${w - 12}`, { stroke: 'currentColor', 'stroke-width': 2.5 });
+ rows.forEach((r, i) => r.forEach((v, j) => T(svg, num(v), { x: 8 + cw * (j + .5), y: rh * (i + .5) + size * .5, size, fill: COLC[j], font: MATH, anchor: 'middle' })));
+ return svg;
+}
+const mul = (A, [x, y]) => [A[0][0] * x + A[0][1] * y, A[1][0] * x + A[1][1] * y];
+
+/* ---------- practice data ---------- */
+const LANDQ = [
+ { A: [[2, 0], [0, 3]], pts: [[1, 1], [-2, 1], [0, -2]] },
+ { A: [[1, 1], [0, 1]], pts: [[1, 2], [-1, 1], [3, -1]] },
+ { A: [[0, -1], [1, 0]], pts: [[1, 0], [2, 1], [-1, 3]] },
+];
+const KINDS = [['st', 'Stretch', COL.irr, 'S'], ['fl', 'Flip', COL.nat, 'F'], ['sh', 'Shear', COL.real, 'H'], ['tu', 'Turn', COL.whole, 'T'], ['sq', 'Squash', COL.task, 'Q']];
+const KINDQ = [
+ { A: [[3, 0], [0, 1]], ans: ['st'], why: '(1, 0) goes 3 times as far, (0, 1) stays: 3 times as wide.' },
+ { A: [[1, 0], [0, -1]], ans: ['fl'], why: '(0, 1) lands on (0, −1): a mirror image, upside down.' },
+ { A: [[1, 0], [2, 1]], ans: ['sh'], why: '(0, 1) stays; (1, 0) leans up to (1, 2): the plane slides.' },
+ { A: [[0, 1], [-1, 0]], ans: ['tu'], why: '(1, 0) lands on (0, −1) and (0, 1) on (1, 0): a quarter turn clockwise.' },
+ { A: [[2, 4], [1, 2]], ans: ['sq'], why: 'Column 2 = 2 × column 1: both point the same way, the plane collapses onto a line.' },
+ { A: [[2, 0], [0, 2]], ans: ['st'], why: 'Both columns twice as long, same directions: everything twice as big.' },
+];
+const READQ = [[[1, 2], [0, 1]], [[0, 2], [-1, 0]], [[2, -1], [1, 1]]];
+
+/* ---------- beats: [id, title, run(m, D), { ask }?] ---------- */
+const BEATS = [
+ ['intro', 'A matrix moves the whole plane', (m, D) => {
+ const g = G(scene, { o: 0, y: 24 });
+ T(g, 'Unit 1, Chapter 10', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });
+ T(g, 'A Matrix Moves the Whole Plane', { x: 800, y: 360, size: 80, weight: 600, anchor: 'middle' });
+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);
+ const r = text(scene, 'every point at once', 800, 450, m('sub'), { size: 36, fill: COL.dim, anchor: 'middle' });
+ const sm = G(scene, { o: 0 });
+ const k = grid2(sm, { A: I2, mat: null, shape: true, plane: { cx: 800, cy: 690, u: 30, x0: -5, x1: 5, y0: -3, y1: 3, labels: false } });
+ show(sm, m('sub') + .5, .6);
+ k.to({ a01: 1 }, m('move'), 1.6); k.to({ a00: 1.4, a10: .4 }, m('move') + 2, 1.4);
+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(sm, D - .9, .8);
+ }],
+
+ ['one', 'Where A sends a point', (m) => {
+ const p = panel(0);
+ text(p, 'A sends each point somewhere', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, A1, { x: [1, 1], grid: false, square: false, shape: false, units: false, t0: m('A') - .4 });
+ g.combo.forEach(e => put(e, { o: 0 }));
+ [g.axArrow, g.axDot, g.axLab].forEach(e => put(e, { o: 0 }));
+ [0, 1].forEach(i => put(g.res(i), { o: 0 }));
+ put(g.parts.cols, { o: 0 });
+ put(g.parts.x, { o: 0 }); show(g.parts.x, m('x'), .4);
+ // by rows, then the answer appears in the brackets and in the plane
+ [0, 1].forEach(i => band(p, DISP[0] + 6, g.lay.A[1][i] - 48, 192, 64, ROWC[i], m('rows') + i * 2.4, m('land')));
+ say(p, ['2·1 − 1 = 1, 1 + 1 = 2'], 90, 480, m('rows') + .4, { size: 36 });
+ [0, 1].forEach(i => { tw(g.res(i), { o: 1 }, m('land'), .4); tw(g.res(i), { o: 0 }, m('x2'), .3); tw(g.res(i), { o: 1 }, m('land2'), .4); });
+ [g.axDot, g.axLab].forEach(e => { show(e, m('land') + .2, .4); hide(e, m('x2'), .3); show(e, m('land2') + .2, .4); });
+ show(g.axArrow, m('land') + .2, .4); hide(g.axArrow, m('many'), .3); hide(g.axDot, m('many'), .3); hide(g.axLab, m('many'), .3); hide(g.parts.x, m('many'), .3);
+ const trail = G(p, {});
+ const tr = (from, to, t) => g.P.arrow(...from, ...to, COL.dim, t, { into: trail });
+ tr([1, 1], [1, 2], m('land'));
+ g.to({ x0: 2, x1: 0 }, m('x2'), .9);
+ say(p, ['2·2 − 0 = 4, 2 + 0 = 2'], 90, 540, m('x2') + 1.6, { size: 36 });
+ tr([2, 0], [4, 2], m('land2'));
+ hide(trail, m('many'), .3);
+ // many dots, each carried to where A sends it
+ const dots = G(p, {});
+ const pts = [];
+ for (let x = -2; x <= 2; x++) for (let y = -2; y <= 2; y++) pts.push([x, y]);
+ // they appear where they are, then all slide together on "Watch"
+ pts.forEach((q, i) => { const special = (q[0] === 1 && q[1] === 1) || (q[0] === 2 && q[1] === 0); carry(g, q, dots, m('many') + .3 + i * .08, { color: special ? COL.task : COL.chalk, dur: 2.4, r: special ? 10 : 7, move: m('go') + .2 }); });
+ text(p, '(1, 1) → (1, 2)', 90, 640, m('check') + .3, { size: 32, fill: COL.task, weight: 600 });
+ text(p, '(2, 0) → (4, 2)', 90, 690, m('check') + 2.2, { size: 32, fill: COL.task, weight: 600 });
+ }],
+
+ ['grid', 'The grid moves', (m) => {
+ const p = panel(0);
+ text(p, 'The whole grid moves', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2, { units: false });
+ put(g.M, { o: 0 }); show(g.M, m('go') + 3, .5);
+ g.to(keysOf(A1), m('go') + .3, 2.6);
+ // one line of the grid, and its neighbour: still straight, still parallel, evenly spaced
+ const L = G(g.P.g, {});
+ [1, 2, 3].forEach((k, i) => { const l = g.P.line(...mul(A1, [0, k]), ...mul(A1, [1, k]), COL.task, (i ? m('par') : m('straight')) + .3 + Math.max(0, i - 1) * .6, { into: L }); hide(l, m('faint'), .4); });
+ const gp = g.P.g.querySelector('path'); tw(gp, { 'a_stroke-opacity': .45 }, m('faint') + .3, .4); tw(gp, { 'a_stroke-opacity': .1 }, m('faint') + 2.6, .6);
+ text(p, 'straight lines stay straight', 90, 480, m('straight') + .4, { size: 30, weight: 600, fill: COL.task });
+ text(p, 'parallel lines stay parallel,', 90, 530, m('par') + .4, { size: 30, weight: 600, fill: COL.task });
+ text(p, 'equally spaced', 90, 575, m('par') + 1.6, { size: 30, weight: 600, fill: COL.task });
+ text(p, 'faint: the plane before A', 90, 640, m('faint') + .4, { size: 28, fill: COL.dim });
+ const sqe = g.parts.square.firstChild; tw(sqe, { 'a_fill-opacity': .4 }, m('sq') + .3, .4); tw(sqe, { 'a_fill-opacity': .12 }, m('sq') + 2.5, .6);
+ text(p, 'the unit square → a slanted box', 90, 700, m('sq') + .4, { size: 28, fill: COL.chalk, weight: 600 });
+ }],
+
+ ['basis', 'Where (1, 0) and (0, 1) land', (m) => {
+ const p = panel(0);
+ text(p, 'Read the matrix off the picture', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, A1, { shape: false });
+ g.labels(['col 1', 'col 2']);
+ put(g.parts.cols, { o: 0 });
+ carry(g, [1, 0], p, m('e1'), { color: COL.irr, dur: 1.4, r: 10 });
+ say(p, ['A·(1, 0) = (2, 1)'], 90, 480, m('e1') + 1.6, { size: 36, fill: COLC[0] });
+ show(g.parts.cols, m('c1'), .4); put(g.cols[1], { o: 0 });
+ colFrame(p, g, 0, m('c1'), m('why'));
+ carry(g, [0, 1], p, m('e2'), { color: COL.real, dur: 1.4, r: 10 });
+ say(p, ['A·(0, 1) = (−1, 1)'], 90, 535, m('e2') + 1.6, { size: 36, fill: COLC[1] });
+ show(g.cols[1], m('e2') + 1.8, .4);
+ colFrame(p, g, 1, m('e2') + 1.8, m('why'));
+ say(p, ['(1, 0) → 1·col 1 + 0·col 2'], 90, 610, m('why') + 2.5, { size: 32 });
+ say(p, ['(x, y) → x·col 1 + y·col 2'], 90, 680, m('all') + 4, { size: 36, fill: COL.task });
+ const st1 = G(p, {});
+ [[0, 0, 1, 0], [1, 0, 2, 0], [2, 0, 2, 1]].forEach(([a, b, c, d], i) => g.P.arrow(a, b, c, d, COL.chalk, m('all') + 1 + i * .6, { into: st1 }));
+ thick(g.cols[0], m('why') + 4.5);
+ hide(st1, m('grid') - .3, .3);
+ // the moved grid is steps of the two columns: walk a few of them
+ const steps = G(p, {});
+ [[0, 0, 2, 1, COLC[0]], [2, 1, 4, 2, COLC[0]], [4, 2, 3, 3, COLC[1]], [3, 3, 2, 4, COLC[1]]].forEach(([a, b, c, d, col], i) => g.P.arrow(a, b, c, d, col, m('grid') + .4 + i * .7, { into: steps }));
+ hide(steps, m('read') - .2, .4);
+ thick(g.cols[0], m('read') + 1.8); colFrame(p, g, 0, m('read') + 1.8, m('read') + 4);
+ thick(g.cols[1], m('read') + 4.2); colFrame(p, g, 1, m('read') + 4.2);
+ text(p, 'column 1 = where (1, 0) lands', 90, 760, m('read') + 1.8, { size: 28, fill: COLC[0], weight: 600 });
+ text(p, 'column 2 = where (0, 1) lands', 90, 805, m('read') + 4.2, { size: 28, fill: COLC[1], weight: 600 });
+ }],
+
+ ['count', 'Counting on the moved grid', (m) => {
+ const p = panel(0);
+ text(p, 'Count steps of the columns', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, A1, { shape: false });
+ g.labels(['col 1', 'col 2']);
+ const P2 = g.P, w1 = G(p, {}), w2 = G(p, {});
+ ring(P2, [2, 1], COL.chalk, w1, m('q'), '');
+ say(w1, ['(2, 1):'], 90, 480, m('q') + .2, { size: 36 });
+ const cs = [P2.arrow(0, 0, 2, 1, COLC[0], m('s1') + .2, { into: w1 }), P2.arrow(2, 1, 4, 2, COLC[0], m('s1') + .9, { into: w1 })];
+ say(w1, ['2·(2, 1) = (4, 2)'], 220, 480, m('s1') + .4, { size: 36, fill: COLC[0] });
+ cs.push(P2.arrow(4, 2, 3, 3, COLC[1], m('s2') + .3, { into: w1 }));
+ cs.forEach((a, i) => thick(a, m('grid') + 2.4 + i * 1.1, 4));
+ say(w1, ['+ 1·(−1, 1)'], 220, 535, m('s2') + .4, { size: 36, fill: COLC[1] });
+ pulse(P2.dot(3, 3, COL.task, m('land') + .3, { label: '(3, 3)', into: w1 }), m('land') + 3);
+ say(w1, ['= (3, 3)'], 220, 590, m('land') + .5, { size: 36, fill: COL.task });
+ carry(g, [2, 1], w1, m('grid') + .2, { color: COL.task, dur: 1.6, r: 9 });
+ say(w1, ['rows: 4 − 1 = 3, 2 + 1 = 3 ✓'], 90, 650, m('rows') + .4, { size: 32 });
+ hide(w1, m('q2') - .3, .4);
+ ring(P2, [-1, 2], COL.chalk, w2, m('q2'), '');
+ say(w2, ['(−1, 2):'], 90, 480, m('q2') + .2, { size: 36 });
+ P2.arrow(0, 0, -2, -1, COLC[0], m('t1') + .3, { into: w2 });
+ say(w2, ['−1·(2, 1) = (−2, −1)'], 250, 480, m('t1') + .4, { size: 36, fill: COLC[0] });
+ P2.arrow(-2, -1, -3, 0, COLC[1], m('t2') + .3, { into: w2 }); P2.arrow(-3, 0, -4, 1, COLC[1], m('t2') + 1, { into: w2 });
+ say(w2, ['+ 2·(−1, 1) = (−2, 2)'], 250, 535, m('t2') + .4, { size: 36, fill: COLC[1] });
+ P2.dot(-4, 1, COL.task, m('land2') + .3, { label: '(−4, 1)', dx: -10, dy: -18, anchor: 'end', into: w2 });
+ say(w2, ['= (−4, 1)'], 250, 590, m('land2') + .5, { size: 36, fill: COL.task });
+ carry(g, [-1, 2], w2, m('back') + .2, { color: COL.task, dur: 1.6, r: 9 });
+ }],
+
+ ['drag', 'Move a column, move the matrix', (m) => {
+ const p = panel(0);
+ text(p, 'Move a column, the matrix moves', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, A1);
+ g.labels(['col 1', 'col 2']);
+ const { PX, PY } = g.P;
+ g.tips.forEach(t => { t._ring.style.opacity = 1; }); // the handles, as the reader will see them
+ pointer(p, [PX(2), PY(1)], [PX(3), PY(0)], m('c1'), 1.6, m('grab') - .2, m('c1n') + 2);
+ g.to({ a00: 3, a10: 0 }, m('c1'), 1.6);
+ colFrame(p, g, 0, m('c1n'), m('grab2')); flash(g, 'a00', m('c1n')); flash(g, 'a10', m('c1n'));
+ pointer(p, [PX(-1), PY(1)], [PX(1), PY(2)], m('c2'), 1.4, m('grab2') - .2, m('c2n') + 2);
+ g.to({ a01: 1, a11: 2 }, m('c2'), 1.4);
+ colFrame(p, g, 1, m('c2n'), m('scrub')); flash(g, 'a01', m('c2n')); flash(g, 'a11', m('c2n'));
+ // a number, scrubbed sideways
+ const [nx, ny] = [g.lay.A[0][0], g.lay.A[1][0]];
+ pointer(p, [nx + 10, ny - 10], [nx + 10 - 44, ny - 10], m('scrubn') - 1.2, 1.6, m('scrub') + 1, m('scrubn') + 2.5, lin);
+ frame(p, nx - 40, ny - 50, 80, 64, COLC[0], m('scrub') + 1, m('same'));
+ g.to({ a00: 1 }, m('scrubn') - 1.2, 1.6, lin);
+ thick(g.cols[0], m('same') + .4); thick(g.cols[1], m('same') + .4);
+ flash(g, 'a00', m('same') + .4); flash(g, 'a10', m('same') + .7); flash(g, 'a01', m('same') + 1); flash(g, 'a11', m('same') + 1.3);
+ text(p, 'move the arrows: the numbers move', 90, 480, m('same') + .6, { size: 30, weight: 600, fill: COL.task });
+ text(p, 'move the numbers: the arrows move', 90, 530, m('same') + 2, { size: 30, weight: 600, fill: COL.task });
+ }],
+
+ ['q1', 'Your turn', () => {
+ const p = panel(0);
+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ ring(g.P, [1, 2], COLC[0], p, undefined, 'column 1 here');
+ ring(g.P, [-2, 1], COLC[1], p, undefined, 'column 2 here', { dx: -20, anchor: 'end' });
+ }, { ask: done => quiz(LEFT, [{
+ id: 'c-cols', prompt: ['Drag the green tip onto ', $m('(1, 2)'), ' and the violet tip onto ', $m('(−2, 1)'), '. What does the matrix say?'],
+ build: g2Task(S.g, v => v.a00 === 1 && v.a10 === 2 && v.a01 === -2 && v.a11 === 1, 'A = [1 −2; 2 1]: column 1 is (1, 2), column 2 is (−2, 1). The plane turns and grows.',
+ 'Column 1 is where (1, 0) lands: its tip goes on (1, 2). Column 2 goes on (−2, 1). You can also type the numbers into the matrix.', () => S.g.set({ a00: 1, a10: 2, a01: -2, a11: 1 }), ['A', 'cols']),
+ }], done) }],
+
+ ['stretch', 'Stretch', (m) => {
+ const p = panel(0);
+ text(p, 'Stretch', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ g.to({ a00: 2 }, m('A') + .3, 1.6);
+ colFrame(p, g, 0, m('c'), m('c') + 4); thick(g.cols[0], m('c') + .3);
+ colFrame(p, g, 1, m('c') + 4, m('see')); thick(g.cols[1], m('c') + 4.3);
+ text(p, 'twice as wide, same height', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task });
+ pulse(g.parts.shape.firstChild, m('flag') + .3, 1.08);
+ tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .55 }, m('flag') + 2, .5);
+ g.to({ a11: 2 }, m('both') + 1, 1.4);
+ text(p, 'two, zero, zero, two: twice as big', 90, 540, m('both') + 1.4, { size: 30, weight: 600, fill: COL.task });
+ }],
+
+ ['flip', 'Flip', (m) => {
+ const p = panel(0);
+ text(p, 'Flip', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ g.to({ a00: -1 }, m('A') + .4, 2);
+ colFrame(p, g, 0, m('c'), m('see')); thick(g.cols[0], m('c') + .3);
+ text(p, 'a mirror image across the y-axis', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task });
+ const mir = path(p, `M${g.P.PX(0)} ${g.P.PY(6.4)}V${g.P.PY(-6.4)}`, { stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '8 8' }, { o: 0 });
+ show(mir, m('see') + .3, .4);
+ tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .55 }, m('flag') + 2, .5);
+ text(p, 'the flag points left', 90, 540, m('flag') + .4, { size: 30, fill: COL.task });
+ }],
+
+ ['shear', 'Shear', (m) => {
+ const p = panel(0);
+ text(p, 'Shear', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ g.to({ a01: 1 }, m('A') + .4, 2);
+ colFrame(p, g, 1, m('c') + 1.6, m('see')); thick(g.cols[1], m('c') + 1.9);
+ const { PX, PY } = g.P;
+ // the bottom line stays, higher lines slide further: arrows show how far
+ const sl = G(p, {});
+ [1, 2, 3].forEach((k, i) => { g.P.arrow(-3, k, -3 + k, k, COL.task, m('see') + 2 + i * .6, { into: sl }); });
+ text(p, 'higher lines slide further', 90, 480, m('see') + 1, { size: 30, weight: 600, fill: COL.task });
+ tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .55 }, m('flag') + 2, .5);
+ }],
+
+ ['turn', 'Turn', (m) => {
+ const p = panel(0);
+ text(p, 'Turn', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ g.turn(0, 90, m('A') + .3, 2.2);
+ colFrame(p, g, 0, m('c'), m('c') + 4); thick(g.cols[0], m('c') + .3);
+ colFrame(p, g, 1, m('c') + 4, m('see')); thick(g.cols[1], m('c') + 4.3);
+ text(p, 'a quarter turn, counterclockwise', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task });
+ const { PX, PY } = g.P;
+ const arc = path(p, `M${PX(2.5)} ${PY(0)}A${2.5 * g.P.u} ${2.5 * g.P.u} 0 0 0 ${PX(0)} ${PY(2.5)}`, { stroke: COL.task, 'stroke-width': 3, fill: 'none' }, { d: 0 });
+ tw(arc, { d: 1 }, m('see') + 1, 1);
+ hide(arc, m('half'), .3);
+ tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .55 }, m('flag') + 2, .5);
+ g.turn(90, 180, m('half') + 1.5, 2.2);
+ text(p, 'minus one, zero, zero, minus one: a half turn', 90, 540, m('half') + 2, { size: 28, weight: 600, fill: COL.task });
+ }],
+
+ ['q2', 'Quick check', () => {
+ const p = panel(0);
+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, [[2, 1], [-1, 1]], { showMat: false });
+ g.labels(['col 1', 'col 2']);
+ }, { ask: done => quiz(TOPL, [{
+ id: 'c-read', prompt: ['Which matrix moved the plane like this? Read the columns off the picture.'],
+ build: blanks([
+ { parts: ['column 1 = (', { box: '2' }, ', ', { box: '-1' }, ')'], why: 'The green arrow: where (1, 0) lands.', hint: 'Column 1 is the green arrow. Where is its tip?' },
+ { parts: ['column 2 = (', { box: '1' }, ', ', { box: '1' }, ')'], why: 'The violet arrow: where (0, 1) lands. So A = [2 1; −1 1].', hint: 'Column 2 is the violet arrow. Where is its tip?', fx: () => fx(S.g.M, { o: 1 }, 0, .5) },
+ ]),
+ }], done) }],
+
+ ['squash', 'Squash', (m) => {
+ const p = panel(0);
+ text(p, 'Squash: the plane falls onto a line', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, I2);
+ g.labels(['col 1', 'col 2']);
+ g.to({ a01: 2, a10: 2, a11: 4 }, m('A') + .4, 2.6);
+ colFrame(p, g, 0, m('c'), m('c') + 3.5); colFrame(p, g, 1, m('c') + 3.5, m('see'));
+ text(p, 'column 2 = 2 × column 1', 90, 480, m('c') + 4.5, { size: 30, weight: 600, fill: COLC[1] });
+ text(p, 'everything lands on one line', 90, 530, m('see') + .4, { size: 30, weight: 600, fill: COL.task });
+ const { PX, PY } = g.P;
+ const d = G(p, { x: PX(2), y: PY(-1), o: 0 });
+ mk('circle', { r: 9, fill: COL.task, stroke: COL.board, 'stroke-width': 2 }, d);
+ const dl = T(d, '(2, −1)', { x: 14, y: 24, size: 22, fill: COL.task, font: MATH });
+ show(d, m('lost') + 1.5, .3); hide(dl, m('lost') + 3, .3); tw(d, { x: PX(0), y: PY(0) }, m('lost') + 3, 1.4);
+ say(p, ['(2, −1) → (2 − 2, 4 − 4) = (0, 0)'], 90, 590, m('lost') + 3, { size: 30 });
+ ring(g.P, [1, 0], COL.bad, p, m('miss') + .5, '(1, 0): never reached');
+ text(p, 'Ax = (1, 0): no solution', 90, 650, m('miss') + 4, { size: 30, weight: 600, fill: COL.bad });
+ thick(g.cols[0], m('miss') + 6); thick(g.cols[1], m('miss') + 6.6);
+ text(p, 'every b? chapter 14', 90, 700, m('miss') + 8.5, { size: 28, fill: COL.dim });
+ g.to({ a00: 0, a01: 0, a10: 0, a11: 0 }, m('zero') + 1, 1.8);
+ hide(g.parts.cols, m('zero') + 2.4, .4);
+ text(p, 'all zeros: one single point', 90, 760, m('zero') + 1.4, { size: 30, weight: 600, fill: COL.task });
+ }],
+
+ ['solve', 'Solving Ax = b', (m) => {
+ const p = panel(0);
+ text(p, 'Solving Ax = b: which point lands on b?', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, [[2, -1], [-1, 2]], { x: [0, 0], shape: false, units: false, t0: m('A') - .4 });
+ g.labels(['col 1', 'col 2']);
+ g.combo.forEach(e => put(e, { o: 0 }));
+ ring(g.P, [0, 3], COL.task, p, m('A') + 6.5, 'b = (0, 3)', { dx: 22, dy: 32 });
+ ['a00', 'a01', 'a10', 'a11'].forEach((k, i) => flash(g, k, m('A') + 1.6 + i * 1.1));
+ pulse(g.axDot, m('q') + .3); pulse(g.xRing, m('q') + 1.2);
+ g.to({ x0: 2, x1: 1 }, m('try') + .3, 1.4);
+ text(p, '(2, 1) → (3, 0): not b', 90, 480, m('try') + 2, { size: 30, fill: COL.bad, weight: 600 });
+ g.to({ x0: 1.5, x1: 1.8 }, m('move') + .2, 1.2);
+ g.to({ x0: 1, x1: 2 }, m('move') + 1.5, 1);
+ pulse(g.axDot, m('found') + .4); pulse(g.xRing, m('found') + .9);
+ text(p, '(1, 2) → (0, 3) = b', 90, 540, m('found') + .6, { size: 30, fill: COL.good, weight: 600 });
+ show(g.combo[0], m('found') + 2, .4); show(g.combo[1], m('found') + 2.6, .4);
+ text(p, 'the solution from chapter 2', 90, 600, m('same') + .5, { size: 28, fill: COL.dim });
+ thick(g.combo[0], m('same') + 2.5, 4); thick(g.combo[1], m('same') + 3.6, 4); pulse(g.xRing, m('same') + 5);
+ ring(g.P, [3, 0], COL.task, p, m('other') + .4, 'b = (3, 0)');
+ text(p, 'b = (3, 0) → x = (2, 1)', 90, 660, m('other') + 1.2, { size: 30, fill: COL.task, weight: 600 });
+ }],
+
+ ['q3', 'Quick check', () => {
+ const p = panel(0);
+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
+ const g = S.g = planeOf(p, [[1, 1], [0, 1]], { shape: false });
+ g.labels(['col 1', 'col 2']);
+ ring(g.P, [2, 1], COL.chalk, p, undefined, '(2, 1) before', { dx: 18, dy: 36 });
+ }, { ask: done => quiz(LEFT, [{
+ id: 'c-where', prompt: ['Where does ', $m('A'), ' send the point ', $m('(2, 1)'), '? Click it.'],
+ build: pickPoint(S.g.P, [3, 1], '2·(1, 0) + 1·(1, 1) = (3, 1). By rows: 2 + 1 = 3 and 0 + 1 = 1.',
+ (x, y) => x === 2 && y === 1 ? 'That is where the point starts. Where does A send it?' : `Not ${pair(x, y)}. Take 2 steps of column 1, (1, 0), then 1 step of column 2, (1, 1).`),
+ }], done) }],
+
+ ['wrap', 'Summary', (m) => {
+ const p = panel(0);
+ [['A moves every point: x goes to Ax.', 'w1'], ['Straight lines stay straight; parallel lines stay parallel, evenly spaced.', 'w2'],
+ ['Column 1 is where (1, 0) lands, column 2 where (0, 1) lands.', 'w3'], ['Stretch, flip, shear, turn, squash. Ax = b: find the x that lands on b.', 'w4']].forEach(([str, mark], i) => {
+ const g = G(p, { x: -16, y: 150 + i * 95, o: 0 });
+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);
+ T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
+ T(g, str, { x: 210, size: 32, weight: 600 });
+ tw(g, { o: 1, x: 0 }, m(mark), .6);
+ });
+ const sm = G(p, { o: 0 });
+ const k = grid2(sm, { A: I2, mat: [560, 610], size: 44, shape: true, plane: { cx: 1200, cy: 700, u: 30, x0: -5, x1: 5, y0: -5, y1: 5, labels: false } });
+ show(sm, .3, .6);
+ k.to(keysOf(A1), m('w1') + 1, 2);
+ k.to({ a00: 3, a10: 0 }, m('w3') + 3.6, 1.2); k.to(keysOf(A1), m('w3') + 6.4, 1.2);
+ thick(k.cols[0], m('w3') + .4); thick(k.cols[1], m('w3') + 1.6);
+ k.to(keysOf([[2, 0], [0, 1]]), m('w4'), 1);
+ k.to(keysOf([[-1, 0], [0, 1]]), m('w4') + 1.6, 1);
+ k.to(keysOf([[1, 1], [0, 1]]), m('w4') + 3.2, 1);
+ k.turn(0, 90, m('w4') + 4.8, 1.2);
+ k.to(keysOf([[1, 2], [2, 4]]), m('w4') + 6.4, 1.2);
+ k.to(keysOf(A1), m('end') - 1, 1.2);
+ }],
+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, LANDQ.map((q, k) => ({
+ id: `p-land${k + 1}`, prompt: ['Where does ', $m('A'), ' = ', matEl(q.A), ' send each point?'],
+ build: blanks(q.pts.map(pt => { const [X, Y] = mul(q.A, pt); return {
+ parts: [`${pair(...pt)} → (`, { box: String(X) }, ', ', { box: String(Y) }, ')'],
+ why: `${num(pt[0])}·col 1 + ${pt[1] < 0 ? `(${num(pt[1])})` : num(pt[1])}·col 2 = ${pair(X, Y)}`,
+ hint: `By rows: (${q.A[0].map(num).join(', ')})·${pair(...pt)} for the first number, (${q.A[1].map(num).join(', ')})·${pair(...pt)} for the second.` }; })),
+ })), done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-kind', prompt: ['What does each matrix do to the plane?'],
+ build: grid(KINDQ.map(q => ({ parts: [matEl(q.A, { size: 24 })], ans: q.ans, why: q.why })), KINDS, { multi: false, text: true }),
+ }], done, 'Chapter practice · set 2 of 4') }],
+ ['final3', 'Chapter practice', () => {
+ const p = panel(0);
+ text(p, 'Read the matrix', 60, 110, .2, { size: 40, weight: 600 });
+ S.g = planeOf(p, I2, { showMat: false });
+ S.g.labels(['col 1', 'col 2']);
+ }, { ask: done => quiz(TOPL, READQ.map((A, k) => ({
+ id: `p-read${k + 1}`, prompt: ['Which matrix moved the plane like this?'],
+ build: (body, api) => {
+ S.g.set(keysOf(A)); put(S.g.M, { o: 0 });
+ return blanks([
+ { parts: ['column 1 = (', { box: String(A[0][0]) }, ', ', { box: String(A[1][0]) }, ')'], why: 'The green arrow: where (1, 0) lands.', hint: 'Column 1 is the tip of the green arrow.' },
+ { parts: ['column 2 = (', { box: String(A[0][1]) }, ', ', { box: String(A[1][1]) }, ')'], why: `The violet arrow. A = [${A[0].map(num).join(' ')}; ${A[1].map(num).join(' ')}].`, hint: 'Column 2 is the tip of the violet arrow.', fx: () => fx(S.g.M, { o: 1 }, 0, .5) },
+ ])(body, api);
+ },
+ })), done, 'Chapter practice · set 3 of 4') }],
+ ['final4', 'Chapter practice', () => {
+ const p = panel(0);
+ text(p, 'Make the move', 60, 110, .2, { size: 40, weight: 600 });
+ S.g = planeOf(p, I2);
+ S.g.labels(['col 1', 'col 2']);
+ }, { ask: done => {
+ const from = f => (body, api) => { S.g.set(keysOf(I2)); return f(body, api); };
+ const is = (v, A) => v.a00 === A[0][0] && v.a01 === A[0][1] && v.a10 === A[1][0] && v.a11 === A[1][1];
+ quiz(LEFT, [{
+ id: 'p-turn', prompt: ['Make ', $m('A'), ' turn the plane a quarter turn ', h('b', '', 'clockwise'), '.'],
+ build: from(g2Task(S.g, v => is(v, [[0, 1], [-1, 0]]), 'A = [0 1; −1 0]: (1, 0) goes down to (0, −1), (0, 1) goes right to (1, 0).',
+ 'Clockwise: (1, 0), pointing right, must end up pointing down, at (0, −1). Where must (0, 1) go?', () => S.g.set(keysOf([[0, 1], [-1, 0]])), ['A', 'cols'])),
+ }, {
+ id: 'p-tall', prompt: ['Make ', $m('A'), ' stretch the plane to 3 times its height, keeping widths.'],
+ build: from(g2Task(S.g, v => is(v, [[1, 0], [0, 3]]), 'A = [1 0; 0 3]: (1, 0) stays, (0, 1) goes 3 times as high.',
+ 'Widths stay: (1, 0) stays where it is. Heights triple: (0, 1) goes to (0, 3).', () => S.g.set(keysOf([[1, 0], [0, 3]])), ['A', 'cols'])),
+ }, {
+ id: 'p-squash', prompt: ['Make ', $m('A'), ' squash the whole plane onto the line through ', $m('(1, 2)'), '.'],
+ build: from(g2Task(S.g, v => (v.a00 || v.a10 || v.a01 || v.a11) && 2 * v.a00 === v.a10 && 2 * v.a01 === v.a11,
+ 'Both columns on the line through (1, 2) (multiples of it, like (1, 2) and (2, 4)): every point lands on that line.',
+ 'Put both column tips on the line through (0, 0) and (1, 2): points like (1, 2), (2, 4), (−1, −2). Not both at (0, 0).', () => S.g.set(keysOf([[1, 2], [2, 4]])), ['A', 'cols'])),
+ }], done, 'Chapter practice · set 4 of 4');
+ } }],
+ ['play', 'Playground', (m, D) => {
+ const p = panel(0);
+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });
+ S.sys = planeOf(p, A1);
+ S.sys.labels(['col 1', 'col 2']);
+ const hint = text(p, 'try: a quarter turn · a flip · put one column on top of the other', 1160, 860, m('go'), { size: 24, fill: COL.dim, anchor: 'middle' });
+ hide(hint, Math.min(m('go') + 9, D - .7), .6);
+ }, { ask: playAsk(() => S.sys, { tip: 'The whole plane, live. Drag a column tip or change a number, or draw on the board. Nothing is marked.' }) }],
+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+
+boot();
+</script>
+</body>
+</html>
diff --git a/site/linear-algebra/lib/grid2.js b/site/linear-algebra/lib/grid2.js
index b2e8147..0afa6c5 100644
--- a/site/linear-algebra/lib/grid2.js
+++ b/site/linear-algebra/lib/grid2.js
@@ -6,10 +6,10 @@
// Loads after engine.js and math.js (it uses plane()).
const G2_COLS = [COL.irr, COL.real], G2_AX = COL.task;
// A small flag: a pole and a pennant pointing right, so a flip or a turn shows at once.
-const G2_FLAG = [[.5, .5], [.8, .5], [.8, 2], [1.9, 2.4], [.8, 2.8], [.8, 3.2], [.5, 3.2]];
+const G2_FLAG = [[.3, .25], [.45, .25], [.45, 1.05], [1.2, 1.3], [.45, 1.55], [.45, 1.75], [.3, 1.75]];
function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54, plane: po = {}, grid = true, square = true, shape = false,
- units = true, pts = [], t0 = .1, hidePlane = false, result = true } = {}) {
+ units = true, pts = [], t0 = .1, hidePlane = false, result = true, showMat = true } = {}) {
const v = { a00: A[0][0], a01: A[0][1], a10: A[1][0], a11: A[1][1], x0: x ? x[0] : 0, x1: x ? x[1] : 0 };
const RANGE = { a00: 9, a01: 9, a10: 9, a11: 9, x0: 9, x1: 9 }, K = 14; // grid lines k = −K … K
const holder = G(p, { o: hidePlane ? 0 : 1 });
@@ -86,9 +86,9 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
const gl = path(gridG, '', { stroke: COL.chalk, 'stroke-opacity': .32, 'stroke-width': 1.6, fill: 'none' });
const axs = G2_COLS.map(c => path(gridG, '', { stroke: c, 'stroke-opacity': .75, 'stroke-width': 3, fill: 'none' }));
const sq = path(sqG, '', { fill: COL.chalk, 'fill-opacity': .12, stroke: COL.chalk, 'stroke-opacity': .7, 'stroke-width': 2.5 });
- const sh = path(shG, '', { fill: COL.task, 'fill-opacity': .55, stroke: COL.task, 'stroke-width': 2, 'stroke-linejoin': 'round' });
+ const sh = path(shG, '', { fill: COL.chalk, 'fill-opacity': .45, stroke: COL.chalk, 'stroke-width': 2, 'stroke-linejoin': 'round' });
path(unG, `M${PX(0)} ${PY(0)}H${PX(1)}M${PX(0)} ${PY(0)}V${PY(1)}`, { stroke: COL.chalk, 'stroke-opacity': .45, 'stroke-width': 3, 'stroke-dasharray': '5 6' });
- [[1, 0, '[1, 0]', 8, 30], [0, 1, '[0, 1]', -70, -12]].forEach(([a, b, s, dx, dy]) => T(unG, s, { x: PX(a) + dx, y: PY(b) + dy, size: 20, fill: COL.dim, font: MATH }));
+ [[.5, 0, '[1, 0]', 0, -12, 'middle'], [0, .5, '[0, 1]', -10, 7, 'end']].forEach(([a, b, s, dx, dy, anchor]) => T(unG, s, { x: PX(a) + dx, y: PY(b) + dy, size: 20, fill: COL.dim, font: MATH, anchor })); // beside the dashed arrows, clear of the axis numbers
const arrowD = (a, c, hl0 = 18) => {
const A1 = [PX(a[0]), PY(a[1])], C = [PX(c[0]), PY(c[1])], L = Math.hypot(C[0] - A1[0], C[1] - A1[1]);
if (L < 1) return '';
@@ -107,10 +107,11 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
const xRing = G(xG, {});
mk('circle', { r: 22, fill: 'transparent' }, xRing);
mk('circle', { r: 9, fill: COL.board, stroke: COL.chalk, 'stroke-width': 3 }, xRing);
- const xLab = T(xG, '', { size: 24, fill: COL.chalk, font: MATH });
+ const xLab = T(xG, '', { size: 24, fill: COL.chalk, font: MATH, anchor: 'end' });
const axDot = G(xG, {});
mk('circle', { r: 10, fill: G2_AX, stroke: COL.board, 'stroke-width': 3 }, axDot);
const axLab = T(xG, '', { size: 26, fill: G2_AX, font: MATH, weight: 600 });
+ [...combo, axArrow, axDot, axLab, xLab].forEach(e => { e.style.pointerEvents = 'none'; }); // only the ring under x takes the pointer
const cols = G2_COLS.map(c => arrow(colG, c));
const tips = G2_COLS.map(c => {
const g = G(colG, {});
@@ -146,6 +147,20 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
}
return `M${XY([P0[0] + a * d[0], P0[1] + a * d[1]])}L${XY([P0[0] + b * d[0], P0[1] + b * d[1]])}`;
};
+ // A polygon cut to the box (Sutherland–Hodgman), so a big stretch never draws past the plane.
+ const poly = pts => {
+ for (const [k, lim, keep] of [[0, box[0], 1], [0, box[1], -1], [1, box[2], 1], [1, box[3], -1]]) {
+ const out = [];
+ pts.forEach((a, i) => {
+ const b = pts[(i + 1) % pts.length], fa = (a[k] - lim) * keep, fb = (b[k] - lim) * keep;
+ if (fa >= 0) out.push(a);
+ if (fa * fb < 0) { const t = fa / (fa - fb); out.push([a[0] + t * (b[0] - a[0]), a[1] + t * (b[1] - a[1])]); }
+ });
+ pts = out;
+ if (!pts.length) return '';
+ }
+ return 'M' + pts.map(XY).join('L') + 'Z';
+ };
function draw() {
slots.forEach(s => s.set());
const c0 = [v.a00, v.a10], c1 = [v.a01, v.a11], ax = map([v.x0, v.x1]);
@@ -161,8 +176,8 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
setD(axs[0], seg([0, 0], c0, -K, K)); // the x-axis lands along column 1
setD(axs[1], seg([0, 0], c1, -K, K)); // the y-axis along column 2
}
- if (square) setD(sq, `M${XY([0, 0])}L${XY(c0)}L${XY([c0[0] + c1[0], c0[1] + c1[1]])}L${XY(c1)}Z`);
- if (shape) setD(sh, 'M' + G2_FLAG.map(q => XY(map(q))).join('L') + 'Z');
+ if (square) setD(sq, poly([[0, 0], c0, [c0[0] + c1[0], c0[1] + c1[1]], c1]));
+ if (shape) setD(sh, poly(G2_FLAG.map(map)));
ptDots.forEach(({ g, lab }, i) => {
const [a, b] = map(ptDots[i].q.p);
put(g, { x: PX(a), y: PY(b) });
@@ -179,7 +194,7 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
setD(combo[1], arrowD(m1, ax, 14));
setD(axArrow, arrowD([0, 0], ax));
put(xRing, { x: PX(v.x0), y: PY(v.x1) });
- put(xLab, { x: PX(v.x0) + 14, y: PY(v.x1) + 30 });
+ put(xLab, { x: PX(v.x0) - 14, y: PY(v.x1) + 30 });
setText(xLab, `x = (${fmt(v.x0)}, ${fmt(v.x1)})`);
put(axDot, { x: PX(ax[0]), y: PY(ax[1]) });
const n = Math.hypot(...ax) || 1;
@@ -196,7 +211,7 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
if (changed) draw();
}
draw();
- if (mat) show(Mx, t0 + .3);
+ if (mat && showMat) show(Mx, t0 + .3); // showMat: false keeps the matrix hidden (a question that asks for it)
const api = {
v, P: P2, stage: holder, M: Mx, lay, cols, tips, combo, axArrow, axDot, xRing, xLab, axLab,
@@ -208,6 +223,13 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
const goal = { ...plan };
prog(q => edit(Object.fromEntries(Object.keys(goal).map(k => [k, from[k] + (goal[k] - from[k]) * q]))), at, dur, ease);
},
+ // Turn the plane from deg0 to deg1 degrees (counterclockwise) on the beat clock: a true turn, where a straight blend
+ // of the numbers would shrink the plane halfway. Later g.to() calls start from where the turn ends.
+ turn(deg0, deg1, at, dur = 1.6, ease = io) {
+ const rot = d => { const a = d * Math.PI / 180, k = n => Math.round(n * 1e6) / 1e6; return { a00: k(Math.cos(a)), a01: k(-Math.sin(a)), a10: k(Math.sin(a)), a11: k(Math.cos(a)) }; };
+ plan = { ...plan, ...rot(deg1) };
+ prog(q => edit(rot(deg0 + (deg1 - deg0) * q)), at, dur, ease);
+ },
// Hands on. what: which parts take the reader's hands: 'A' the matrix numbers, 'cols' the column tips, 'x' the point x and its numbers.
live(on, what = ['A', 'cols', 'x']) {
live = on;
@@ -220,8 +242,8 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,
if (s.on) s.box.setAttribute('tabindex', 0); else s.box.removeAttribute('tabindex');
}
const cOn = on && what.includes('cols'), xOn = on && what.includes('x');
- tips.forEach(g => { g.style.cursor = cOn ? 'grab' : ''; g._ring.style.opacity = cOn ? 1 : 0; });
- xRing.style.cursor = xOn ? 'grab' : '';
+ tips.forEach(g => { g.style.cursor = cOn ? 'grab' : ''; g._ring.style.opacity = cOn ? 1 : 0; g.style.pointerEvents = cOn ? '' : 'none'; });
+ xRing.style.cursor = xOn ? 'grab' : ''; xRing.style.pointerEvents = xOn ? '' : 'none'; // a handle not in play never hides one that is
},
set: edit, // at once, for a reader's action or an answer shown
num: key => slots.filter(s => s.key === key).map(s => s.t), // the text that shows this value (to flash it)