We already know how to implement motion to an object with a given velocity. In this section, we will add acceleration to our model. [br][br]To start, we can use part of the script we wrote in the first example. [br][br]We will need to define the l[i]ocation[/i], the [i]circle[/i] and its [i]velocity[/i]:[br][br][code]#Location[br]xlocation = 2[br]ylocation = 2[/code][br][br][code]#Ball[br]O=(xlocation, ylocation)[br]c=Circle(O, 1)[/code][br][br][code]#Velocity. In this case we can start with the value 0 for each entry.[br]xvel= 0[br]yvel = 0[/code][br][br]Now we can introduce the [i]acceleration[/i]:[br][br][code]#Acceleration[br]xacc = -0.005[br]yacc = 0.003[/code][br][br]We already know how to update the [i]location[/i] of the ball using the expression:[br][br][i]location[/i] = [i]location[/i] + [i]velocity[/i][br][br]However, we want to implement [i]acceleration[/i] to our model. To update the velocity of the ball, we can use the expression: [br][br][i]velocity[/i] = [i]velocity[/i] + [i]acceleration[/i][br][br]To do this, we have to write in the slider [i]Run[/i] the lines:[br][br][code]SetValue(xvel, xvel + xacc)[br]SetValue(yvel, yvel + yacc)[br][/code][br]and then[br][br][code]SetValue(xlocation, xlocation + xvel)[br]SetValue(ylocation, ylocation + yvel)[br][/code][br]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.[br][br]One way to do this is by defining the velocity components as sliders:[br][br]xspeed = Slider(-0.8, 0.8, 0.001, 1, 140, false, true, false, false)[br]yspeed = Slider(-0.8, 0.8, 0.001, 1, 140, false, true, false, false)[br][br]Using these values will restrict the velocity components to the interval [-0.8, 0.8][br][br]Compare this implementation with the following applet.
Download file: [url=https://www.geogebra.org/material/show/id/vqydwkpz]Velocity and Acceleration[/url]
Try implementing velocity and acceleration with a random location of the ball or with a different acceleration at the beginning. [br][br]You can also try implementing a bouncing ball with velocity and acceleration.