Phase 01 · Week 1 · 120 minutes

Day 7: Matrices from grids: inputs, outputs, and simple actions

Meet the robot, then meet the maths · Start with a physical robot and build every maths idea from counting, measuring, arrows, and grids.

Chapter 01 · Meet the robot, then build its mathematical language

Today in the field story

One problem, then the next

The sorter’s final paper controller must apply the same arrow action every time a parcel reaches the lane marker. Build identity, scale, reflection, and quarter-turn cards, then run the Parcel-Sorting Desk Robot’s target vector through each row by row. Finish by showing why a plain 2×2 card cannot add a fixed translation and by reproducing the checked Node.js output.

Why now

Matrices package repeatable component rules and complete the week’s physical-to-numerical dictionary.

Ignore today

Ignore large matrices, eigenvalues, and homogeneous coordinates until the next mission needs them.

Unlocks next

Rotation matrices, rigid transforms, forward kinematics, and numerical inverse kinematics.

Understand

Build the physical picture first

A matrix is a compact rule machine: each row tells how to calculate one output component from all input components.

A matrix is a rectangular arrangement of numbers. It can store data, but in this lesson it represents a declared linear action on a column vector. The matrix shape tells what sizes fit: a 2×2 matrix accepts a two-component input and returns a two-component output. Meaning also depends on conventions such as axis order, frame, units, and whether vectors are written as columns.

Matrix–vector multiplication is repeated multiply-and-add work. For each output, take one matrix row, multiply its entries by the matching input components, and add. The first row produces the first output component; the second row produces the second. Do not multiply entries only by position and stop—the addition inside each row is essential.

The identity matrix [[1,0],[0,1]] leaves every input unchanged. A diagonal matrix [[2,0],[0,1]] doubles x while leaving y unchanged. The matrix [[−1,0],[0,1]] reflects across the y-axis and reverses handedness. The quarter-turn matrix [[0,−1],[1,0]] rotates column vectors by +90° under the standard x-right, y-up convention. Drawing known test vectors makes sign and convention errors visible.

Not every physical operation fits a plain 2×2 matrix. A rotation or scale about the origin is linear, but adding a fixed translation is not: a linear matrix must send the zero vector to zero. Later, homogeneous coordinates will place rotation and translation into a larger matrix representation. For now, state exactly what the 2×2 input and output mean and test the rule with the basis arrows (1,0) and (0,1).

Words you need

Name each idea precisely

Matrix

A rectangular number array used here as a declared input-to-output linear rule.

Physical example:

A 2×2 rotation matrix maps a 2D arrow to a turned arrow.

Row

A horizontal matrix line that calculates one output component.

Physical example:

The first row computes output x.

Column vector

An input or output vector written vertically in this convention.

Physical example:

The arrow (2, 0) written as two stacked numbers.

Identity matrix

A square matrix that leaves compatible vectors unchanged.

Physical example:

Applying [[1,0],[0,1]] to (1,2) returns (1,2).

Linear transformation

A rule that preserves vector addition and scalar multiplication and sends zero to zero.

Physical example:

Rotation about the origin, scaling, or reflection through an origin line.

Basis vector

One of the unit axis arrows used to build and test all vectors in the space.

Physical example:

e₁ = (1,0) and e₂ = (0,1) in 2D.

Visual model

See the relationship

Swipe the technical canvas horizontally on a small screen.Matrices from grids: inputs, outputs, and simple actions — math diagramA two-by-two number grid turns the paper arrow (2,0) into (0,2), one row at a time. Row rule works: Each row produces the expected output component. The displayed measure is 0 wrong outputs.xyOv=(2,0)R₉₀v=(0,2)Math anchor
Day 7 · Math checkEach row produces the expected output component. Measured anchor: 0 wrong outputs.

Math, one line at a time

Work through today’s relationship

Prerequisite rescue · optionalStart at zero: counting, units, and coordinates

No maths is assumed. First give every robot number a physical meaning, a unit, a zero point, and a positive direction.

N
a count, such as number of jointsUnit: no unit
x
one position measured from a chosen zeroUnit: centimetres (cm) or metres (m)
Δx
change in x; Δ means changeUnit: same unit as x
  1. Draw a number line. Put the origin at 0 cm, choose right as positive, and place the robot at x = 20 cm.

  2. Move 30 cm right, so Δx = +30 cm. Predict x_new = 20 cm + 30 cm = 50 cm.

  3. Measure to check, then convert with 100 cm = 1 m: 50 cm = 0.50 m. Never add centimetres directly to metres.

Programmer analogy

A variable is like a named field in code, but a robot field must also say its physical unit and what zero means.

A robot starts at x = 40 cm and moves 15 cm left. What is its new x coordinate?

Left is negative, so Δx = -15 cm and x_new = 40 - 15 = 25 cm.

The identity action is

Iv=[1001][xy]=[xy].I\mathbf v=\begin{bmatrix}1&0\\0&1\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}x\\y\end{bmatrix}.

A quarter-turn is

[0110][20]=[02].\begin{bmatrix}0&-1\\1&0\end{bmatrix}\begin{bmatrix}2\\0\end{bmatrix}=\begin{bmatrix}0\\2\end{bmatrix}.

Apply a quarter-turn matrix one row at a time

Use R = [[0,−1],[1,0]] and input v = (2,1) as a column vector.

  1. Check dimensions: a 2×2 matrix can multiply a two-component column vector.

  2. Compute output x from row one: 0×2 + (−1)×1 = −1.

  3. Compute output y from row two: 1×2 + 0×1 = 2.

  4. Write the complete output Rv = (−1,2).

  5. Draw v and Rv and verify a 90° counterclockwise turn.

  6. Check length: √(2²+1²) = √5 and √((−1)²+2²) = √5.

Result

The matrix maps (2,1) to (−1,2) and preserves length, matching a pure quarter-turn rotation.

What this proves

Row-by-column arithmetic plus a geometric check exposes swapped order or sign errors.

Physical examples

Where this appears in real life

Rotate a paper arrow

A paper arrow initially points two squares along +x and is turned 90° counterclockwise around the origin.

Look for:

The input (2,0) becomes (0,2), and its length remains two squares.

Mirror a camera overlay

A selfie preview reflects horizontal coordinates while leaving vertical coordinates unchanged.

Look for:

The mapping (x,y) → (−x,y) is a reflection, not a physical camera rotation, and it reverses handedness.

Hands-on exercise

Make the idea observable

Make four paper cards for identity, x-scale by 2, x-reflection, and +90° rotation; use squared paper.

  1. Write each 2×2 matrix and its intended physical action on a separate card.

  2. Apply every card to e₁ = (1,0) and e₂ = (0,1) one row at a time.

  3. Use those two outputs to predict the result for v = (1,2).

  4. Calculate each full result and draw input plus output arrows.

  5. Check which actions preserve length and which reverse handedness.

  6. Attempt to represent “move every point +2 along x” with a 2×2 matrix and use the zero-vector test to explain why it fails.

Observe

The transformed basis arrows reveal the whole linear action; the translation attempt fails because a 2×2 linear matrix cannot move zero away from zero.

Done when

All twelve matrix–vector results are correct, drawn, labelled with convention, and the translation limitation is explained using the zero vector.

Build today

Build a paper two-link robot and a browser notebook that shows its parts, allowed motion, coordinates, vectors, frames, and matrices.

Evidence to save

DONE when the weekly ship note explains how “Matrices from grids: inputs, outputs, and simple actions” changed the build, what still fails, and the first task for next week.

Common mistakes

Catch the wrong mental model

Wrong

Multiplying corresponding entries without summing each row.

Better

Each output component is a dot product between one matrix row and the input column.

Wrong

Changing between row-vector and column-vector conventions silently.

Better

Declare the convention and keep matrix order consistent throughout the calculation and code.

Wrong

Calling a reflection a rotation because both move arrows.

Better

Test handedness and length; reflection reverses orientation even when length is preserved.

Wrong

Trying to encode a fixed translation in a plain 2×2 linear matrix.

Better

A linear map sends zero to zero; use addition separately now and homogeneous coordinates later.

Job connection

How this becomes employable evidence

Test coordinate, image, and learned-action transformations with known basis inputs before connecting them to a 3D viewer, planner, or robot command interface.

Relevant target roles

  • Robotics Software Engineer — ROS 2 / AMR
  • Robot HMI / Control & Monitoring Engineer
  • Robot Learning Deployment / Physical AI Integration Engineer

Chapter 01 interview drill

Interview questions: Matrices from grids: inputs, outputs, and simple actions

Practise a 60–90 second answer: define the idea, connect it to a physical robot, state assumptions, frames, and units when relevant, then finish with the failure signal or evidence you would inspect.

Primary interview scenario

A 2D overlay is mirrored and rotated the wrong way. How would basis-vector tests, frame conventions, and the zero-vector test isolate the matrix error?

Answer shape: clarify the situation → trace the physical and software path → test the most likely boundaries → name the evidence that would confirm the result.

Technical follow-up questions

Q1What does the first row of a 2×2 matrix calculate under the column-vector convention?
Model interview answer

It multiplies and adds the two input components to produce the first output component.

Q2How can two basis-vector tests reveal a 2D linear transformation?
Model interview answer

Every 2D vector is a weighted sum of the two basis vectors, and a linear rule preserves that combination.

Q3Why can no 2×2 linear matrix perform the same +2 x translation for every point?
Model interview answer

Every linear matrix maps the zero vector to zero, while that translation would map zero to (2,0).

Chapter starter artifact

Audit one framed parcel move

A labelled paper arm and Node.js audit show the complete sense–decide–act–observe loop, two independent joints, six configurations, framed parcel coordinates, a checked vector calculation, and a matrix action whose predicted output matches the drawing.

week-01-parcel-sorter.mjsLanguage: JavaScriptDownload starter
const mission = "parcel-sorter";
const parts = ["sensor", "controller", "actuator", "feedback"];
const frame = { name: "table", unit: "m", origin: [0, 0] };
const move = [3, 4];
const norm = Math.hypot(move[0], move[1]);
const quarterTurn = [
  [0, -1],
  [1, 0],
];
const apply = (matrix, vector) => matrix.map(
  (row) => row[0] * vector[0] + row[1] * vector[1],
);
const turned = apply(quarterTurn, move);
const loopComplete = parts.at(-1) === "feedback";
const numericContract = frame.origin.concat(move, quarterTurn.flat()).every(Number.isFinite);
if (frame.unit !== "m" || !loopComplete || !numericContract ||
    turned[0] !== -4 || turned[1] !== 3) throw new Error("invalid contract");
console.log("mission=" + mission);
console.log("parts=" + parts.join(">"));
console.log("move=(3,4) norm=" + norm.toFixed(2) + "m");
console.log("quarterTurn=(" + turned.join(",") + ")");
console.log("status=PASS");

Download the file into your terminal's current folder, then run the command below. The expected output is exact.

Run

node week-01-parcel-sorter.mjs

Expected output

mission=parcel-sorter parts=sensor>controller>actuator>feedback move=(3,4) norm=5.00m quarterTurn=(-4,3) status=PASS

Planted failure to diagnose

Change the quarter-turn matrix to [[0,1],[-1,0]]. The output becomes (4,-3), revealing a reversed rotation/handedness convention even though the arithmetic still runs.

Topic reference