FixTheRobot Explore Robotics / Linear Algebra / M2 / M2-L1

This lab works on phones, but writing code is much easier on a laptop.

Linear Algebra · Matrices and Linear Transformations · M2-L1 · Beginner

Matrix Transformation Playground

Robot scenario

Scout, the delivery robot, carries a camera that sees the world through a matrix: every pixel direction is turned, stretched or sheared before it reaches the planner. If you can read a matrix as a picture, you can debug the camera.

You will first move a shape with the two columns of a matrix, then catch the classic bug of multiplying in the wrong order, and finally write the code that recovers a matrix from examples and collapses a whole motion script into one matrix.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and lakit (import lakit as la: vectors, matmul, solve, qr, svd, eigh, lstsq, pinv and more; NumPy is not available in the browser). Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 is hands-on: the two arrows are the columns of a 2 × 2 matrix, and the whole shape follows them. Stage 2 is the diagnosis: rotating then stretching is not the same as stretching then rotating. Stage 3 asks you to write fit_matrix, which solves M S = D for the matrix from two examples. Stage 4 asks for compose, which multiplies a list of steps in the right order and decides whether the result can be undone.

    Grading is result-based. Your functions run on the example and on freshly generated hidden cases, and are compared with exact results to six decimal places. The hidden cases include reflections, shears and a script with a zero scale, because those are the cases that break first.

    You can use plain Python, math, and the small linear algebra library lakit (import lakit as la): la.matmul, la.inv, la.solve, la.det and more. It runs in your browser; NumPy is not available there.

    Theory for this lab

    Matrices and Linear Transformations labs

    1. M2-L1: Matrix Transformation Playground: this lab.

    Educational simplification: linear maps of the plane only (no translation; that arrives with homogeneous transforms in Module 7). Angles are in degrees in the script and radians in the maths.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.