Orbital Motion: Eccentricity

This activity involves taking the code at the end of the Slingshot with Gravity exercise and adding some code to it to measure the eccentricity. This activity is also connected to the Orbital Motion: Kepler's 2nd law activity, but you do not need to complete that activity before working on this one unless your teacher asks you to.

The goal of this activity is to measure the "eccentricity" of the orbit. Eccentricity is a measure of how different from a circle the orbit is. An eccentricity of zero means that the orbit is a perfect circle. An eccentricity of 0.8 or higher means that the orbit is not very circular at all. The maximum eccentricity is 1.

Note that if the velocity is too large the object will move far away from the central massive object (in this case the sun) and never come back. We are going to focus on orbits where this does not happen. An activity where we explore when this does happen is Escape Velocity / Newtonian Black Holes.

Step 1. Open up the code

Click here to open the code from the end of Slingshot with Gravity

Sign in to your account or create an account. Then click "Duplicate" so you can have your own version of the code!!!

When you press play at the top left corner of the screen the program will look a lot like this:

Step 2. Launch the Object with the mouse (or your touch screen)

You can launch the object from different positions and with different velocities using the mouse or a touch screen. With a mouse you can click and drag in the direction you want to launch the object. When you let go of the left click button it will launch the object. Likewise, with a touch screen (for example on an iPad) you can touch the screen, drag your finger in the direction you want it to go and when you let go the object will be launched that way.

The longer you drag the cursor the faster the launch velocity will be. Notice that for some velocities the object moves far away and never comes back. In this exercise, we are trying to AVOID this.

Step 3. Launch the object by changing the initial velocity and position in the code

Another way to get a different orbit is to change the initial vx and vy at the beginning of the program.

Here are the default values:

x = 525;
y = 250;

vx = 0;
vy = 20;

Change these numbers and see how it affects the orbit. Try to AVOID setting the initial vx or vy so large that the object moves very far away and never comes back.

Step 4. Learn about eccentricity

We are going to measure the eccentricity by first measuring the max and the min distance in the orbit.

For an object orbiting the sun the max distance is called "aphelion" ($r_a$) and the closest distance is called "perihelion" ($r_p$). A helpful way to remember which one is the max distance is that "ap" means "away".

If we can measure $r_p$ and $r_a$ we can calculate the eccentricity from this formula: $$ {\rm eccentricity} = \frac{r_a - r_p}{r_a + r_p} $$

Step 5. Add code to measure the max and min distance

First add variables for rmax and rmin to the beginning of your code:

rmin = 1000;
rmax = 0;

Next, towards the end of the draw function add this code:

  drawText('Perihelion = ',width/2-125,height/2-125); 	
  if (rmin > r)    rmin = r;
  drawText(rmin,width/2+40,height/2-125);

  drawText('Aphelion = ',width/2-125,height/2-150);
  if (rmax < r)    rmax = r;
  drawText(rmax,width/2+40,height/2-150);

Step 6. measure the eccentricity

Now add code to calculate the eccentricity and write the value to the screen

    eccentricity = ????;  // fix this!
    drawText('eccentricity = ',width/2-100,height/2-200);
    drawText(eccentricity,width/2+25,height/2-200);  

It's up to you to figure out what to replace ???? with. Note that for the default parameters (x = 525; y = 250; vx = 0; vy = 20;) you should get an eccentricity of 0.4

Step 7. Demonstrate e = 0, e = 0.5 and e = 0.8

Now that your code can measure eccentricity, try to figure out the initial values for x,y,vx and vy that give you e = 0 (circular orbit), e = 0.5 (oval), and e = 0.8 (wide oval)

As you figure out these values write them down! at the beginning of your code like this:

// eccentricity of 0.7
x = 525;
y = 250;

vx = 0;
vy = 20;


// eccentricity of ??
//x = ???;
//y = ???;

//vx = ???;
//vy = ???;

Useful trick: To print the initial x,y, vx and vy to the screen add this code to the beginning of your program:

showinitial = true;

This is especially helpful if you are using the mouse or the touch screen to launch the object.