Every position, every velocity, every "which way is the enemy looking" in every game ever shipped is a vector. It's just two numbers drawn as an arrow — and the only math you need to unlock it is the Pythagoras you already know.
press play — 90 seconds ↓Plays like the video — one caption at a time, the picture animating under it — and it pauses when it's your turn to drag something. Skip around with the dots or arrow keys. The full lab comes after.
An arrow is just two numbers: how far across (x)
and how far up (y). That's it. And because those two legs make a right triangle,
the arrow's length comes free — it's Pythagoras, the one formula school
actually made you memorize. Drag the tip and watch the triangle do the work.
Walk along a, then walk along b — where do you
end up? That's a + b, and the math is embarrassingly easy: add the x's,
add the y's, done. Subtraction is the same trick: a − b is just
"walk a, then walk b backwards". Drag both tips, flip the sign, watch the ghost.
Multiply the x's, multiply the y's, add them up. One number falls out — and that number is a "same direction?" meter. Point B with A and it reads +1. Perpendicular? 0. Dead against A? −1. The disc shows the whole story: everything in the green half of A's world is "in front", the red half is "behind" — and the halves rotate with A. Drag both arrows.
This is the dot product's day job. The guard has a facing direction and a
field of view. Take the direction to the player, normalize it, dot it with the
guard's facing — if the result beats cos(fov/2) and the player is in range,
you're spotted. Every stealth game you've ever played runs this exact
two-line test. Drag the player. Try to stay alive.
N·L — surface normal
dotted with the light direction, once per pixel, millions of times a frame.
That's chapter 04.The stealth test from this chapter, exactly as a game runs it: the guard's facing (yellow arrow) dotted against to-player (cyan arrow). When the dot beats cos(fov/2) and the range check passes, the cone goes red. Widen the FOV and watch hiding get harder.
Click any moment on the right — it takes you straight there (in place when this site is served over http, on YouTube when opened as a local file).