This project is a collection of interactive simulations that use the Monte Carlo method to solve mathematical and physical problems in a visual and intuitive way.
The project features two main simulations:
- Pi Calculation - Uses the Monte Carlo method to approximate the value of Pi through random points in a square and circle.
- Shadow Simulation - Demonstrates how the Monte Carlo method can be used to simulate realistic shadow projection with penumbra effects.
Each simulation includes an explanatory section that describes the theory and mathematical principles behind the application of the Monte Carlo method.
- Interactive React-based user interface
- Real-time visualization of simulation results
- Ability to modify parameters such as number of points/rays
- Drag and drop for elements in the simulations
- Responsive design with TailwindCSS
The simulation generates random points within a square. By counting how many points fall inside an inscribed circle, we can approximate Pi using the formula: π ≈ 4 × (points in circle / total points).
The simulation generates random rays from a light source and traces their path through the scene. Shadow intensity is calculated based on the density of rays blocked by the obstacle.
- Clone this repository
- Install dependencies:
npm install
# or
yarn install- Start the development server:
npm run dev
# or
yarn dev- Open your browser and navigate to
http://localhost:3000
- Create a new React component in the components/ directory
- Create an associated explanation component
- Add a new page in app/ that imports both components
- Update navigation to include the new page
- Next.js (App Router)
- React
- TypeScript
- TailwindCSS
- HTML Canvas for renderings
Contributions are welcome! Feel free to open issues or pull requests to improve existing simulations or propose new Monte Carlo method implementations.