"Every linear transformation in 2D is completely described by where two arrows land. This game lets you feel that fact."
An interactive fullscreen C++ game that teaches linear algebra through real-time visualization, puzzles, guided lessons, and failure-driven learning.
| Mode | What It Does |
|---|---|
| Puzzle Mode | 10 heist levels testing transformations |
| Free Play | Experiment with any matrix, explore freely |
| Interactive Lessons | 8 guided visual lessons with proofs |
| Coordinate Race | Mini-game proving matrix = basis-vector recipe |
| Misconception Quiz | 8 T/F questions targeting common errors |
- Hover over any matrix cell → tooltip explains its geometric meaning
- Determinant flash animation → yellow flash on sign change, red warning when det=0
- Visual warnings → "COLLAPSE! 2D → 1D" or "ORIENTATION FLIPPED (mirror image)"
After solving, click "Why did that work?" to see:
- The exact matrix you used
- The geometric story in plain English
- A common misconception callout (failure-driven learning)
- Real-world applications
Try the wrong transform? The game shows you exactly why it fails:
- "You tried scaling instead of translation — the origin stays stuck!"
- "You translated before rotating — order matters!"
- Visual proof of the failure right on the grid
In Free Play, toggle basis trails to see ghost paths of where î and ĵ have traveled. Every transformation leaves a fading trail, making the connection between successive transforms visceral.
Every level ends with a card showing where that transform shows up:
- Translation → GPS, game character movement
- Rotation → Drone heading, Photoshop rotate
- Shear → Italic fonts, deskewing documents
- Projection → 3D rendering, PCA in machine learning
- Composition → Every neural network layer, every GPU frame
A dedicated viewer showing step-by-step matrix composition:
- Step 1: Original shape
- Step 2: After Rotation
- Step 3: After Scale (on top of rotation)
- Step 4: After Translation (complete chain)
- Shows the final combined matrix
Prove that matrix multiplication and the basis-vector recipe are the same operation:
- Point P starts at (2, 1.5)
- Path A: direct matrix multiplication
A*P - Path B: manual recipe
x·î_new + y·ĵ_new - Both arrive at the exact same spot — visually
8 targeted questions between levels:
- "True or False: A 2×2 matrix can slide a square 5 units right." → False (needs affine 3×3)
- "Which preserves area but distorts shape?" → Shear
- "Matrix multiplication is commutative." → False (order matters!)
- Every wrong answer comes with a detailed explanation
| Level | Mission | Skill | Real-World |
|---|---|---|---|
| 1 | Drive car to pickup spot | Translation | GPS, game movement |
| 2 | Rotate and park at curb | Rotation + Translation | Robotic arms, parking assist |
| 3 | Squeeze through tight gate | Scaling | Image zoom, microscopy |
| 4 | Lean ladder to window | Shear X | Italic fonts, deskewing |
| 5 | Align with 45° tunnel | Rotation | Drone heading, Photoshop |
| 6 | Reflect and reach vault | Reflection + Translation | CT scans, mirror symmetry |
| 7 | Stretch across bridge | Scale X | Aspect ratio correction |
| 8 | Shrink & rotate to fit keyhole | Scale + Rotate | Camera zoom-pan |
| 9 | Flatten to slide under lasers | Projection | 3D rendering, PCA in ML |
| 10 | Chain 4 transforms together | Full Composition | Every neural network |
| Lesson | What You Learn | Interactive Feature |
|---|---|---|
| 1. Determinant | det = ad - bc, signed area |
Change matrix, see parallelogram |
| 2. Dot Product | `a·b = | a |
| 3. Projection | `proj_u(v) = (v·u/ | u |
| 4. Inverse Matrix | A⁻¹ undoes A |
Toggle inverse grid overlay |
| 5. Eigenvectors | A·v = λ·v |
Watch eigenvectors stay on their line |
| 6. Cramer's Rule | Solve Ax=b with determinants |
Move RHS vector |
| 7. Column & Null Space | Span vs kernel | Change matrix, see space collapse |
| 8. Basis Change | Same point, different coords | Rotate basis |
| Key | Action |
|---|---|
F11 |
Toggle fullscreen |
ESC |
Quit |
| Key | Action |
|---|---|
1-9 |
Select transformation |
T |
Translation |
P / O |
Project to X / Y |
C |
Custom matrix editing |
G |
Toggle ghost grid |
D |
Toggle determinant |
Mouse Wheel |
Adjust parameter |
Shift + Wheel |
Adjust secondary parameter |
| Key | Action |
|---|---|
Wheel |
Adjust lesson parameter |
Shift + Wheel |
Secondary adjustment |
SPACE (Inverse) |
Toggle inverse overlay |
1 / 2 (Eigen) |
Toggle eigenvector lines |
build.batOr manually:
g++ -O2 -std=c++17 -I. -Ilib/raylib-src/src main.cpp -Llib/raylib-src/src -lraylib -lopengl32 -lgdi32 -lwinmm -o linalg_vis.exe.
├── main.cpp # ~700 lines: game, puzzles, 8 lessons, quiz, race, visualizers
├── linmath.h # Vectors, matrices, eigenvalues, inverses, Cramer's rule
├── build.bat # Windows build script
├── lib/raylib-src/ # Raylib graphics library (compiled)
└── README.md
The same intuition you just built scales directly to AI:
- Matrix multiplication → every layer of every neural network
- Eigenvectors → PageRank, PCA, spectral clustering
- Projection → dimensionality reduction, autoencoders
- Composition → deep networks (layer after layer of transforms)
- Null space → adversarial examples exploit null spaces of weight matrices
This game teaches the math that powers GPT, Stable Diffusion, and every game engine.
Educational project. Raylib is licensed under zlib/libpng license.