Angles and atan2
Four beacons round a ship on a radar: radians and degrees, why atan(y / x) gets half of them wrong, how atan2 gets all four, compass bearings, wrapping, and the shortest turn.
Open it in the simulatorThe math under every game and instrument, in C++ on an ESP32-C3: vectors, atan2, rotation, matrices, easing and smoothing, ending in a ship's compass needle on a screen.
0 of 7 done
7 lessons in 4 chapters, about 5 hours on a simulated ESP32-C3-DevKitM-1. Free, in your browser, every step checked by the simulator.
Four beacons round a ship on a radar: radians and degrees, why atan(y / x) gets half of them wrong, how atan2 gets all four, compass bearings, wrapping, and the shortest turn.
Open it in the simulatorSix numbers that move, turn and grow a ship at once: 2D affine matrices, why the order of a product matters, the determinant as an area, and an inverse that turns a screen tap into ship coordinates.
Open it in the simulatorA shaky compass heading from the LIS3MDL, smoothed three ways: why averaging angles fails at north, averaging vectors instead, and an exponential filter that trades lag for calm.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
Vectors for motion and direction, and atan2 for which way to turn.
A capsule drifting toward a docking port, in vectors: add and scale for motion, length and normalize for speed and direction, and the dot product for ahead or behind.
0 of 5 steps
Four beacons round a ship on a radar: radians and degrees, why atan(y / x) gets half of them wrong, how atan2 gets all four, compass bearings, wrapping, and the shortest turn.
0 of 5 steps
Rotation by sine and cosine, and six numbers that do it all at once.
Turn a ship outline with sine and cosine: the rotation formula, why it turns clockwise on a screen, how small float errors pile up, and turning about a pivot instead of the corner.
0 of 5 steps
Six numbers that move, turn and grow a ship at once: 2D affine matrices, why the order of a product matters, the determinant as an area, and an inverse that turns a screen tap into ship coordinates.
0 of 5 steps
Interpolation that feels alive and filters that calm a shaky sensor.
Glide a ship from a station to a dock: lerp, a vector lerp for a path, smoothstep easing that starts and stops gently, and turning a needle the short way around.
0 of 5 steps
A shaky compass heading from the LIS3MDL, smoothed three ways: why averaging angles fails at north, averaging vectors instead, and an exponential filter that trades lag for calm.
0 of 4 steps
A ship's compass on a screen.
A ship's compass from the LIS3MDL: atan2 for the heading, a vector filter for calm, a rotation matrix for the needle, the short way around, declination for true north and the cardinal point in big letters.
0 of 5 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Vectors, trig and matrices for code are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated ESP32-C3-DevKitM-1 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Angles and atan2, Matrices and Noise and smoothing.
With "Vectors", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.