Interactive simulation of the Buffon's Needle experiment — drop needles onto a lined surface and watch
Buffon's Needle is an 18th-century probability problem: if you drop a needle of length
A needle crosses a line when its centre is within half a projection of the needle's length onto the perpendicular direction:
where
Integrating over all positions and angles gives the crossing probability:
After
The more needles, the closer it gets. Usually.
- Animated canvas — watch needles accumulate in real time
- Click anywhere on the canvas to drop a needle at that exact spot
- Speed control from "one needle every 50 frames" up to 200 per frame
- Dark and light mode
- UI in English, Czech, German and French (picked automatically from browser language)
- Parameters and live stats in a single tabbed panel
git clone https://github.com/sejtam-dev/buffons-needle.git
cd buffons-needle
npm install
npm run devThen open http://localhost:3000.
npm run build # production build
npm run lint # ESLint- Next.js 16 (App Router)
- TypeScript 5
- Tailwind CSS v4
- HTML5 Canvas API
src/
├── app/ # layout, page, global CSS
├── components/ # NeedleCanvas, SidebarPanel, InfoModal, LocaleSwitcher
├── context/ # ThemeContext
├── hooks/ # useSimulation
├── i18n/ # translations + useLocale
└── types/ # shared interfaces
MIT © 2026 sejtam-dev