Skip to content

Bouncing Ball in a Rotating Hexagon

Run MicroSim in Fullscreen Edit in the p5.js Editor

Copy this iframe to your website:

1
<iframe src="https://dmccreary.github.io/microsims/sims/ball-in-rotating-hexagon/main.html" width="100%" height="470px"></iframe>

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:

  1. Projecting the ball's position onto each hexagon edge
  2. Detecting when the ball overlaps an edge
  3. Computing the relative velocity between the ball and the moving wall
  4. 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:

  1. Set the rotation speed to zero and observe pure gravitational bouncing
  2. Increase rotation speed and note how the ball gains energy from the walls
  3. Try negative rotation speeds and compare the ball's behavior
  4. 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