Archive

Archive for March, 2015

Announcements

March 25, 2015 Leave a comment

1. No more reading quizzes.  I am tired of writing them and I don’t think they are doing too much in terms of helping.  From now on, just read the book and we can all be happy.

2. I forgot to pass back the chapter 6 quiz today.  I will give you extra time to submit a video reassessment for this standard.

Categories: Uncategorized

Energy and Launching stuff

March 23, 2015 Leave a comment

Here is a comparison of launching rockets from a mountain vs. the equator.

http://www.wired.com/2011/07/space-shuttle-launch-equator-vs-mountains/

Categories: Uncategorized

Equations for chapter 6

March 19, 2015 Leave a comment

06_allproblems_pdf__page_2_of_116_

Categories: Uncategorized

Colliding Planets Problem

March 17, 2015 Leave a comment

Here is the problem I suggested in class.

Categories: Uncategorized

Videos for Chapter 6

March 10, 2015 Leave a comment

Categories: Uncategorized

GlowScript Tutorial 7: Useful Projectile Motion

March 10, 2015 Leave a comment

Now you know enough stuff (from previous tutorials) to do something useful.  Let’s start with a simple question: at what angle should you shoot a projectile to get the maximum range?  If you just shout out “45 degrees” – you just memorized that.  Let’s see if we can reproduce that with GlowScript.

Here is a starter program. http://www.glowscript.org/#/user/rhettallain/folder/phys221/program/GStutorial7changingprojectile

It looks like this:

GlowScript_IDE

This program first creates a function called “proj” (which is short for projectile motion).  You give the function an initial velocity magnitude and angle and it models a thrown ball with that same starting velocity.  The model shows the motion of the ball starting from y = 0 back to y = 0 (so on flat ground).  The inside of the function looks just like your previous projectile motion program.

Notice that the function does not have a “return” statement.  Instead, it just displays the motion of the ball.  After the function, there are three instances that call the function.  All start with the same initial speed but at different angles.  When you run it, you get this:

GlowScript_IDE

Notice that I didn’t bother to draw the ground.  Why would that matter?  In fact, I don’t need to draw the ball at all.  If I don’t make a sphere, GlowScript won’t create the 3d environment.  Let me remove the sphere from the function and have it return the final x position.  Here’s what the function now looks like.

GlowScript_IDE

This is essentially the same program.  The big difference is the lack of objects (sphere) and the function returns the final x position and time.  When you run it, you get this.

GlowScript_IDE

Each time the function is called, it prints out both the final x and the final time.  I could just print the x position with this line.

GlowScript_IDE

Since the function produces two values, it gives them as a list.  We can reference the first item in a list as proj(4,.2)[0] and the second item as proj(4,.2)[1] (remember that lists start with the index 0 not 1).

We are now ready to do some serious stuff.  Here is the plan.  Pick some starting launch velocity and some angle (a small angle).  Run the projectile function and produce the final position of the projectile.  Plot the starting angle and the final position.  Repeat until you get to some very large angle.  This should make a graph.

Here is a starter program with some blanks for you to fill in.

http://www.glowscript.org/#/user/rhettallain/folder/phys221/program/maxrangeexample

And this is the important part (the program won’t run until you fix it.

GlowScript_IDE

Clearly “stuff” shouldn’t be there.  You will need to make some changes.  Also notice that I used the variable v and theta1 instead of v0 and theta.  Since these same variables are used inside the function, some would say it would be bad form to also use them outside the function.

When you fix it, you should get an output like this:

GlowScript_IDE

This shows a maximum range at around 45 degrees.  Boom.  Oh, why is the line squiggly?  I will let you play with the code and see if you can figure that one out.

Next, something super useful.  I mean, we already knew the answer for maximum range, right?  What if I shoot the ball from a starting location that is 1 meter above the ground?  At what angle will it go a maximum distance?  Hint: you only need to change one thing in your program.  Double hint: here is the output you should get.

GlowScript_IDE

Homework

There are many things left to explore.  Here are some things you can try.

  • What is the launch angle that gives the greatest time of flight?
  • What if you add air resistance (see a previous tutorial)?  What is the launch angle for a ping pong ball fired at a speed of 12 m/s?
  • What if you start the ball on the ground a distance of 1 meter away from a vertical wall?  What angle should you launch the ball (speed of 4 m/s) so that it hits the vertical wall at the highest point?
  • If you shoot the ball starting 1 meter off the ground, does the angle for max range change with launch speed?
  • What if you start from the ground and launch up to a table that is 1 meter off the ground?  What is the angle for the maximum range?  This is a little bit tougher since you will need to change the loop condition in your projectile function.
Categories: Uncategorized

GlowScript Tutorial 6: Functions

You want to do cool stuff with numerical calculations, right?  Well, you can only go so far before you need to learn about functions.

Actually, functions aren’t anything new.  You have already used functions like mag() and norm().  Let’s make our own function.  Take a look at the following simple program.

GlowScript_IDE

When you run that, it should look like this:

GlowScript_IDE_and_Inbox__40__-_rhett_allain_selu_edu_-_Southeastern_Louisiana_University_Mail

This function is created in line 3 with “def”.  Test is the name of the function and x and y are the two parameters that you pass to it.  Anything indented after the def statement is part of the function.  The “return” line tells the function what to give back when you call it.

Maybe that sounds confusing.  Of course this “test” function is sort of silly.  How about I make a function that recreates the magnitude of a vector.  It would look like this.

GlowScript_IDE

Be aware that I have to use a unique name for this function.  I couldn’t call it “mag” since that’s already used.  Anything inside the function (like tempmag) only exists inside the function.  I can give three different things to the function when I call it.

  • A variable that is a vector (like A or B).
  • A vector – like vec(-1,3,4)
  • or a scalar (like 3).

Here is what happens when I run this program.

GlowScript_IDE

It appears that the first three times the function works correctly.  When you give it a scalar, the function basically replies “dude.  I don’t know what you are doing.”  Your function uses the components of a vector.  If you don’t give it a vector, it won’t work.  The output says “NaN” which stands for “Not a Number”.

Ok, one more function.  What if I want to sum the numbers up to a certain number.  For instance, if I gave it 4, I would want it to calculate 1+2+3+4 = 10.  Here is that function.

GlowScript_IDE

I guess I should have talked about loops first.  Right?  I feel dumb now although I technically DID talk about loops in previous tutorials when we used the “while” loop.  Here is another kind of loop, he “for” loop.  This “for” loop makes values of i for everything in n.  Here is a super simple loop example.

GlowScript_IDE

Running gives this:

GlowScript_IDE

You can use any variable instead of “i” – but it will start from the value 0.  That’s why my dumb counting function adds i+1 to the sum for each loop.  Maybe it was a bad example of a function.

In the next tutorial we will do some physics using functions.

GlowScript Tutorial 7: Useful Projectile Motion

Categories: Uncategorized