Bouncing Balls in Desmos Graphing Calculator
by Nelly151 in Design > Animation
51 Views, 2 Favorites, 0 Comments
Bouncing Balls in Desmos Graphing Calculator
In this project, users can make realistic bouncing animations inside of a graphing calculator.
This project is a very brief sample of the potential of animation using mathematics.
Supplies
For this project, I used the Desmos Graphing Calculator (https://www.desmos.com/calculator) and the Desmos 3d calculator (https://www.desmos.com/3d).
What is Desmos?
The Desmos Graphing Calculator is a free, web-based tool used to plot mathematical equations, functions, and data points. It features interactive sliders that let users create graphs in real time to visualize how changing variables impacts an equation. Widely used in schools, it also serves as the official built-in calculator for major standardized exams like the Digital SAT. Desmos also features an experimental 3D calculator which can visualize equations with a z-axis.
Create a Circle in Desmos
As you may recall from algebra, the equation for a shaded circle with center at (a,b) and radius r is:
(x-a)²+(y-b)²≤r²
If we write this in Desmos, create sliders for a and b, and input a radius such as 4.4, we will have a circle which can move in straight lines.
After this, change the shading of the circle to be fully solid.
Add Gravity to the Ball
However, gravity in real life doesn’t move objects at a constant pace.
As objects are pulled downwards, they accelerate faster until they hit and floor and bounce upwards.
Now, one may notice that the trajectory of a bouncing ball mimics a quadratic equation.
We can use this to our advantage to create a realistic bouncing animations by squaring the b inside of (x-a)²+(y-b)²≤r².
When you square a variable, the output ‘accelerates’ as the variable increases, mimicking gravity.
Now, after flipping the sign of the b (to make the y-value decrease as b increases) inside of (x-a)²+(y-b²)²≤r², the resulting expression (x-a)²+(y+b²)²≤r² will appear to “bounce” when the sliders are played.
Add Boundaries
Now that we have a bouncing ball, we need to adjust this ball to fit within our desired parameters.
Currently, the ball bounces far below the x-axis, which is an unwanted output. We can fix this by adjusting the sliders and directly adding to the y-value of the center of the circle.
To adjust a slider, click on the slider and change the interval limits to adjust the domain of the slider. Increasing the interval limits of the y-slider will result in taller bounces, whereas adjusting the limits of the x-slider will change how far the ball bounces before reversing.
For my values, i chose -60<a<60 and 0<b<10.
It is important that b either stops at 0, or continues until it hits an identical negative value, or else the ‘gravity’ will not work properly due to the way a quadratic equation is mirrored on the y-axis.
Now, to move the ball above the y-axis, simply subtract the squared value of the maximum/minimum that b will reach into the y-value for your circle.
For example, I added 100 to (x-a)²+(y+b²)²≤4.4², resulting in (x-a)²+(y+b²-100)²≤4.4².
Create Walls
To create ‘walls’ or boundaries for the ball to bounce off of, we can add equations for line segments.
For the wall at y=0, use the equation y=0{-60<x<60}
For the walls at -60 & 60, use the equation |x|=60{0<y<120}
(the curly brackets denote the domain/range of the x/y values)
You may change the color of the boundaries by holding on the icons for the lines.
For visual appeal, click on the wrench icon in the top right, and turn off Grid, Arrows, X-axis, and Y-axis.
Account for the Radius of the Ball
Now that the ball bounces above y=0 and between |x|=60, we have to account for the radius of the ball in our calculations.
Right now, the ball’s center hits at y=0 and |x|=60, but for more realistic bounces, the ball should bounce once one of its edges hit the boundaries.
To fix this for lateral movement, add/subtract the radius of the balls from the intervals for the a-slider.
To fix this for horizontal movement, shift the ball up by the radius by subtracting the radius from the y-value in the equation for the circle, resulting in the equation (x-a)²+(y+b²-100-4.4)²≤4.4².
Create More Balls!
Congradulations! You have now made a bouncing ball.
You can create more balls using the steps listed above, but make sure to use different variables for each ball .
You can customize the balls by changing their color, bounce height, bounce speed, and lateral speed.
- To change the color, hold on the equation for the ball and select a color.
- To change the bounce height, increase/decrease the spread of b (and make sure to account for this in the equation for the circle!)
- To change the bounce speed and lateral speed, click on the loop symbol to the left of the sliders and adjust the speed as desired.
If you are creating more balls, arrange your equations in folders for organization.
A finished result should look like this: https://www.desmos.com/calculator/lijovhtjoq
Create in 3d
If you want to, you can also create a ball in 3d!
To create a 3d ball, go to Desmos 3D and use the equation (x-a)² +(y-b)²+(z-c)²=r² .
The same principles apply, but instead of moving upwards with the y-axis, you move upwards with the y-axis and side-to-side with both the y and x axes.
A finished 3d bouncing ball should look like this: https://www.desmos.com/3d/wy1evpadbb
Thank you for reading! I hope you enjoy creating your own bouncing balls using mathematics!