Bouncing Balls Inside a Circle

Create physics simulations of bouncing balls inside a circle.

This is an online physics simulation of bouncing balls inside a circle. With this tool you can create custom simulations of bouncing balls inside a circle and generate videos.

You can customize the simulation by changing parameters like the number of balls, the radius of the balls, the radius of the circle, the gravity and more. For each ball you can set the initial position and velocity.

You can also customize the visualization, including colors of the balls, glow effects, light effects, ball trajectories and more.

During the simulation, you can change the animation speed, the circle radius, the radius of the balls, the gravity or other parameters.

To learn more about each configuration parameter, read the documentation below.

If you want, you can record and download videos of your simulations. The simulation videos will be generated using webm extension. You are free to share the generated videos on YouTube, TikTok or any other social media or website. Attribution is not required but appreciated.

Canvas size
Initial conditions

Ball #1

Ball #2

Ball #3
Circle
Physics
Visualization
Trajectory

Balls

Lights
Chaos visualization

Ball #1

Ball #2

Ball #3
Coordinates
You can also change the offset by clicking and dragging your mouse on the canvas.
Zoom
You can also change zoom by scrolling the mouse wheel on the canvas.
Background
Audio
Animation speed
Animation control
Elapsed time: 0 ms
Generate and download video
Elapsed time: 0 ms

Configuration parameters

Canvas size

FieldDescription
ResolutionThe canvas width and height, in pixels. You can select an option from the list of commom display resolutions, or use "custom" to choose any width and height.
WidthThe width of the animation canvas, in pixels.
HeightThe height of the animation canvas, in pixels.

Initial conditions

FieldDescription
Number of ballsThe number of balls for the simulation. These balls will be created inside the circle.

You can configure the initial position and initial velocity for each ball.

FieldDescription
Position xInitial x coordinate of the ball.
Position yInitial y coordinate of the ball.
Speed xInitial horizontal velocity of the ball.
Speed yInitial vertical velocity of the ball.

Circle

FieldDescription
Circle radiusThe radius of the big circle, in pixels. All balls will bounce inside this circle.
Line thicknessThe line width of the circle.

Physics

FieldDescription
GravityThe gravity.
High precisionIf high precision is enabled, there will be multiple physics updates for each animation frame. This will make the simulation more precise, but may cause it to become slower also.
StepsIf high precision is enabled, you can configure the number of steps (physics updates) for each animation frame. More steps means more precision in simulation.

Visualization

In this section you can configure how you want to visualize the simulation, including some nice effects.

Trajectory

FieldDescription
Show trajectoryIf enabled, the simulation will show the trajectories (trails) of the balls.
Trajectory lengthThe ball trajectory length, in animation frames. You should avoid setting very large trails because it may cause the simulation to become slow.
Trajectory widthThe width of the trajectory, in pixels.
Glow trajectoryIf enabled, the trajectory will have a glow effect (neon).
Glow widthIf the glow trajectory is enabled, this will set the width of the glow.

Balls

FieldDescription
Show balsIf enabled, the simulation will render the balls. You can disable this option if you only want to see the balls trajectory, for example.
Ball radiusThe radius of the balls.
Ball color generationThis option set how the color of the balls will be generated. It can be a different color for each ball or a different color for each simulation (if you enable the "chaos visualization" option).
Connect ballsIf enabled, the balls will be connected with a line. This line don't affect the simulation physics, only the visualization.

Lights

FieldDescription
Show lightsIf enabled, the balls will have a light effect, similar to glow or neon.
Light intensityThe intensity of the light effect.
Light radiusThe radius of the light effect.

Chaos visualization

The "chaos visualization" allows you to render multiple simulations in a single animation or video. This works by making multiple independent simulations in parallel, and joining them together by combining each simulation as a layer in the resulting animation frames.

To enable the chaos visualization, just set the field "number of simulations" to a value grater than 1. You need to restart the simulation for this to take effect.

FieldDescription
Number of simulations

The number of simultaneous visualizations of the simulations.

Each simulation will tipically have a small change in the initial position of one or more balls. You can configure these offsets (see table below). These changes in the initial positions cause increasing differences in the positions over time, that you can visualize in this online tool.

Large number of simulations can cause the animation to become slow. However, you can record videos using this online tool, so that the generated videos will keep the configured framerate. The generated videos will always have the configured framerate, even if the recording process takes too long.

If you enable chaos visualization (by setting the number of simulations to a value greater than 1), you can configure the fields "offset x" and "offset y" for each ball. All balls must have offset x or offset y different than zero, otherwise you will not be able to see the differences in the trajectories.

FieldDescription
Offset xThe change in the horizontal position of the ball, for each simulation. For example, if the "position x" is set to 100 and the "offset x" is set to 1, the initial x coordinate of the balls will be 100, 101, 102, 103 and so on.
Offset yThe change in the vertical position of the ball, for each simulation. For example, if the "position y" is set to 100 and the "offset y" is set to 1, the initial y coordinate of the balls will be 100, 101, 102, 103 and so on.

Coordinates

FieldDescription
OriginThe coordinates origin (0,0). Can be "top left" or "center".
Offset xThe "x" coordinate offset, in pixels. It determines the horizontal position of the "camera". Adjusting this offset lets you shift the view or "move" the camera.
Offset yThe "y" coordinate offset, in pixels. It determines the vertical position of the "camera". Adjusting this offset lets you shift the view or "move" the camera.

Zoom

FieldDescription
ZoomChanging this parameter allows you to "zoom in" or "zoom out".

Background

FieldDescription
Transparent backgroundIf this option is checked, the animation will have transparent background.
Background colorThe background color, in hexadecimal value. For example, use #000000 for a black background.

Audio

FieldDescription
Play sound on ball collisionIf enabled, a sound will be played when a ball collides with the circle.
Volume based on collision speedIf enabled, when the collision occurs, the sound volume will be louder when the ball is moving faster.
VolumeThe audio volume, in decibels.
Max polyphonyThe maximum number of sounds that can be played simultaneously.
FrequencyThe audio frequency, in hertz (Hz).
DurationThe audio duration, in seconds.
VelocityVelocity is how forcefully a note is played. It affects the volume. It ranges from 0 (silent) to 1 (maximum volume).

Animation speed

FieldDescription
Animation speedThe speed of the animation. Values greater than 1 means the animation will play in "fast motion".

Animation control

FieldDescription
StartStart the simulation.
RestartRestart the simulation.
PausePause the simulation.
ResumeResume the simulation.
StopStop the simulation.

During the simulations, you can download the current animation frame at any time.

FieldDescription
Download current animation frameDownload current animation frame (in PNG format).

Generate and download video

Instead of only watching the simulations online, you can also record and download videos of your simulations. The simulation videos will be generated using webm extension.

You are free to share the generated videos on YouTube, TikTok or any other social media or website. Attribution is not required but appreciated.

FieldDescription
FramerateThe amount of frames per second that you want the video to have.
Automatically stop after...If enabled, the video recording will stop automatically after the configured time (in seconds) or after the configured amount of frames.

Related tools

Three-Body Problem Simulation

Three-Body Problem Simulation

Create simulations of the Three-Body problem.