Bouncing Ball in a Rotating Hexagon
Run MicroSim in Fullscreen Edit in the p5.js Editor
Copy this iframe to your website:
1 | |
About This MicroSim
This simulation demonstrates a ball bouncing inside a rotating hexagon. The ball is affected by:
- Gravity: A constant downward force pulls the ball
- Friction: Air resistance gradually slows the ball
- Collision Detection: The ball bounces off the rotating hexagon walls
- Momentum Transfer: The rotating walls impart velocity to the ball on collision
Use the Speed slider to control the hexagon's rotation speed. Positive values rotate clockwise, negative values rotate counter-clockwise. Watch how the rotating walls affect the ball's trajectory and energy.
How It Works
The simulation calculates collisions by:
- Projecting the ball's position onto each hexagon edge
- Detecting when the ball overlaps an edge
- Computing the relative velocity between the ball and the moving wall
- Reflecting the ball's velocity and adding energy from the rotating wall
Lesson Plan
Learning Objectives:
- Understand how gravity affects projectile motion
- Observe momentum transfer between moving surfaces and objects
- Explore how rotation speed affects system dynamics
- Visualize collision detection and response algorithms
Activities:
- Set the rotation speed to zero and observe pure gravitational bouncing
- Increase rotation speed and note how the ball gains energy from the walls
- Try negative rotation speeds and compare the ball's behavior
- Find settings that create stable orbital patterns
Discussion Questions:
- Why does the ball gain or lose energy based on rotation direction?
- How does the hexagon shape affect bouncing patterns compared to a circle?
- What real-world systems exhibit similar rotating boundary collisions?
References
- p5.js Documentation - Official p5.js reference
- 2D Collision Detection - MDN collision detection guide
- Special thanks to Linas Beliƫnas for the suggestion