This is an old revision of the document!


Essential Computational Skills

Adapted from John Plough's materials for HS Physics

The following is an introduction to using VPython in GlowScript. Once logged in, the Help button in the upper right hand corner of the screen contains a useful introduction along with tutorials and extensive object descriptions for assistance well beyond material presented here.

While working these activities in pairs, make to comment each line of code you write to remind yourself and your partner what it does and why you wrote it. You can comment code by using the pound symbol,

# This is a commented line in Glowscript

It is important that you are your partner agree and understand each line of code you are writing. The comments are meant to externalize that understanding you both share.

Draw Physics

One of the central features of Glowscript is being able to make objects that represent different things in the world. Making objects with Glowscript is much simpler than other languages and one of Glowscript's strengths. In this activity, you and your partner are tasked with using Glowscript's shape objects to write the word PHYSICS, Physics, or physics.

Shape objects are often the first part of the program that gets written because you are “setting the scene.” The point of this activity to understand better the different attributes of Glowscript's shape objects, how they work, and how you can refer to the different attributes.

Modeling a sliding crate

Making objects move across the screen involves a loop. This is typically a while loop that runs a block of code repeatedly until some condition is met (called “the loop control condition”). In this activity, you and your partner should create a crate and a surface that represents a frictionless floor. The crate should rest on the floor.

In your program, give the crate an initial velocity and model its motion for a few seconds. Make sure to comment each line of code you write.

Adding a MotionMap

Once you and your partner have completed this, look at the instructions for including a MotionMap for your crate. Make sure to comment each line of additional code you write.

You will need to add this line to the top of your program to include the module that makes MotionMap active,

get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js')

Graphing the Kinetic Energy

Once you and your partner have complete this, calculate the kinetic energy of the crate in every time step. Look at how to make a graph using Glowscript and graph the kinetic energy of the crate as a function of time. Make sure to comment each line of additional code you write.

What do you expect the kinetic energy graph to look like?

Can you change this to a graph of speed vs time? What about the position vs time?

A crate comes to a stop

Now that you have a working program that models the motion of a crate over a frictionless surface, let's see what happens when the crate then hits a rough patch. Add a piece of flooring to the end of the frictionless floor that is rough (make it a different color). When the crate hits that patch it should now experience a frictional force. Model the motion of the crate as it moves across the frictionless floor and into the rough patch. You are free to choose relevant parameters. Make sure to comment each line of additional code you write.

How does the MotionMap change?

How do the graphs of kinetic energy, speed, and position vs time change?

  • summer_2018/essential_skills.1529385310.txt.gz
  • Last modified: 2018/06/19 05:15
  • by pwirving