logo
By Lawrence

5 minutes

Trick Shots

Trick shots live after the first hit. A kick shot bounces the cue ball off a rail before it reaches a ball. In a combination, your ball knocks one ball into another. In a carom, the cue ball glances off one ball into the next. The ghost ball can't show any of that.

The whole shot

To see a whole shot, move every ball. Copy the table, strike the copy, and run the table's own step on it until all sixteen balls stop. Keep a line of where each ball went. simulateShot does that with stepTable, the same function play runs, the same 1/120 s step and the same ball order: by number, as the table sorts them. So the forecast lands where the real balls land, to nine decimal places in BilliardTable's tests. One difference: in play a scratched cue ball comes straight back on the head spot, while the forecast just ends its line in the pocket.

src/components/BilliardTable/BilliardTable.core.ts
for (let step = 0; step * dt < maxTime; step++) {
  stepTable(runBalls, n, table, dt);
  let moving = false;
  for (let i = 0; i < n; i++) {
    const b = runBalls[i];
    if (b.out) continue;
    if (zoneCount > 0 && zoneAt(b.p, zones, zoneCount) >= 0) {
      b.out = true;
      b.v.fill(0);
      b.w.fill(0);
      out.potted[i] = true;
      mark(out, i, b.p, true);
      continue;
    }

Every step, a ball that reaches a pocket is out, and its line ends there. A ball still moving gets a new point every 1.5 cm. When nothing moves, the run is over. Here is a full-power break:

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search