Google Classroom
GeoGebraGeoGebra Classroom

Velocity and Acceleration

We already know how to implement motion to an object with a given velocity. In this section, we will add acceleration to our model. To start, we can use part of the script we wrote in the first example. We will need to define the location, the circle and its velocity: #Location xlocation = 2 ylocation = 2 #Ball O=(xlocation, ylocation) c=Circle(O, 1) #Velocity. In this case we can start with the value 0 for each entry. xvel= 0 yvel = 0 Now we can introduce the acceleration: #Acceleration xacc = -0.005 yacc = 0.003 We already know how to update the location of the ball using the expression: location = location + velocity However, we want to implement acceleration to our model. To update the velocity of the ball, we can use the expression: velocity = velocity + acceleration To do this, we have to write in the slider Run the lines: SetValue(xvel, xvel + xacc) SetValue(yvel, yvel + yacc) and then SetValue(xlocation, xlocation + xvel) SetValue(ylocation, ylocation + yvel) The following applet shows the result. Go ahead, activate the animation and see what happens!
Well, after a couple of seconds, the ball goes too fast. The animation does not work very well. We need to find a way to restrict the value of the velocity, so it does not increase infinitely. One way to do this is by defining the velocity components as sliders: xspeed = Slider(-0.8, 0.8, 0.001, 1, 140, false, true, false, false) yspeed = Slider(-0.8, 0.8, 0.001, 1, 140, false, true, false, false) Using these values will restrict the velocity components to the interval [-0.8, 0.8] Compare this implementation with the following applet.

Final result

Exercise

Try implementing velocity and acceleration with a random location of the ball or with a different acceleration at the beginning. You can also try implementing a bouncing ball with velocity and acceleration.