This commit is contained in:
Schluffe
2026-09-04 13:57:52 +02:00
parent 71cfa64793
commit e961887953
24 changed files with 340 additions and 360 deletions
+3 -2
View File
@@ -9,13 +9,14 @@ A **vector** here is nothing mystical: a pair of numbers `(x, y)`. We use the
same value to mean two different things depending on context:
- a **position** — a point in the world.
- a **displacement / velocity** — an arrow: "move this much in x, this much in y."
- a **displacement / velocity** — an arrow: "move this much in x, this much in
y."
That's it. All of 2D physics is built on adding, subtracting, and scaling these
pairs.
- `add(a, b)` → `(a.x + b.x, a.y + b.y)` — apply an arrow to a point.
- `sub(a, b)` → `(a.x - b.x, a.y - b.y)` — the arrow that points *from b to a*.
- `sub(a, b)` → `(a.x - b.x, a.y - b.y)` — the arrow that points _from b to a_.
- `scale(a, s)` → `(a.x * s, a.y * s)` — make an arrow longer/shorter.
> Note: we return **new** objects (pure functions) here for clarity. Your real