# Giving an Object a Speed and Direction

BHS -> Staff -> Mr. Stanbrough ->IP How-To Notes -> this page

Very often we would like to simulate a problem like:

A ball is kicked with an initial speed of 24.0 m/s at an angle of 38.0o from the horizontal...

but Interactive PhysicsTM does not seem to have a convenient, straightforward way to give an object a particular starting speed in a particular direction. Fear not!

## The "Brute Force" Method

 This object will have a starting velocity of 24.0 m/s at an angle of 38o from the horizontal.
One fairly obvious method would be to simply calculate the velocity components outside the program (using a calculator) by:

and then enter the results in the vx and vy fields of the object's Properties Window. In the example above, for instance:

vx = (24.0 m/s) cos (38.0o) = 18.912 m/s

vy = (24.0 m/s) sin (38.0o) = 14.776 m/s

In order to change the starting speed or angle, you will need to recalculate the velocity component's values and re-enter them in the Properties Window.

## A Better Method:

 This object also has a a starting velocity of 24.0 m/s at an angle of 38o from the horizontal.
One of the most powerful abilities of the Interactive PhysicsTM software is its ability to accept a formula just about anywhere that you might "normally" type a value. This means that you can have the program calculate the velocity components for you, instead of calculating them and typing them into the Properties Window.

You need to be aware, however, that Interactive PhysicsTM deals only with angles in radians, so a simple degrees-to-radians conversion has to be done many cases. (That is what the "pi/180" in the example at right does.)

To change the speed and/or angle values, you can edit the vx and vy fields in the object's Properties Window.

## The "Fancy" Way - Using Controls:

 Selecting "Speed and Direction" from the "New Controls" submenu of the Define Menu adds these two controls to the simulation. Here is the Properties Window.
If you select the object with the mouse and pull down the Define Menu, you will see the New Control submenu, which contains the menu item "Speed and Direction". If you select it, you get the situation shown at right.

 At right is a screen shot of the simulation, ready to start. The speed of the ball will be 24.0 m/s at an angle of 38o. The Properties Window for the projectile. The formulae for the velocity components have been modified to convert the input to degrees. The Properties Window for the Speed control. Speeds can be from 0 to 30 m/s, in increments of 1 m/s. Of course, any value in the allowable range can be typed into the text box. The Properties Window for the Direction control. Directions between 0 and 90o in increments of 1o can be selected on the slider.
You will undoubtedly need to do some editing in the Properties Windows of the two controls that are created. For the speed control, you should edit the min and max values to allow the range of speeds you want - the default speeds are relatively slow.

Remember that Interactive PhysicsTM works in radian mode. If you want to specify direction in degrees, the example Properties Window at right shows how to do it.

BHS -> Staff -> Mr. Stanbrough ->IP How-To Notes -> this page
last update July 19, 2000 by JL Stanbrough