10230

# Balls Bouncing off Walls

The patterns here are suggested by collisions of colored balls according to the laws of mechanics. Balls with diverse sizes and colors fall under the influence of customizable acceleration due to gravity. They can hit up to three projection walls and bounce back. If a ball leaves the cube, it disappears. Balls interact only with the walls but not with one another. There are several effects that you can set for the projection walls.

### DETAILS

The collision between a ball and a projection wall surface changes only the velocity vector component along the normal direction at the point of collision on . Before the collision, if the ball's velocity vector is and the unit normal at is , then can be written as where and . After collision, the velocity vector becomes . If the projection wall surface is a plane, then determining an accurate collision point is easy; but if is curved surface, this can be somewhat time-consuming and yields little benefit since the ball's radius is relatively small when compared to the simulation region. Therefore to calculate more quickly, we simply use the sphere center's coordinate and a that is obtained by solving the equation as the point of collision.
When a ball hits more than one wall at once, we treat the multiple collisions as follows: if all walls are planes, we write and change it to where or according to which collision happens along the direction. If a wall is a curved surface, then we first deal with the collision on this surface alone using the method described in the previous paragraph and then deal with the remaining collisions on the plane walls.
This Demonstration is inspired by "Create Unique Charts with Different Visualizations" and "Use Symbolic Graphics Primitives to Visualize Results". A few videos of this Demonstration can be downloaded from the author's personal page.
Possible Issue
The reset button may flicker once after it is clicked, but this does not cause any trouble.

### PERMANENT CITATION

 Share: Embed Interactive Demonstration New! Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details » Download Demonstration as CDF » Download Author Code »(preview ») Files require Wolfram CDF Player or Mathematica.

#### Related Topics

 RELATED RESOURCES
 The #1 tool for creating Demonstrations and anything technical. Explore anything with the first computational knowledge engine. The web's most extensive mathematics resource. An app for every course—right in the palm of your hand. Read our views on math,science, and technology. The format that makes Demonstrations (and any information) easy to share and interact with. Programs & resources for educators, schools & students. Join the initiative for modernizing math education. Walk through homework problems one step at a time, with hints to help along the way. Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet. Knowledge-based programming for everyone.