![]()
Intro to Isaac -- a brief adventure with Sir
Isaac Newton's laws
Begin with a brief look at a computer program that lets you see and
experience how objects behave where there is no gravity or friction. Then you can learn as much as you like about
the program and how it works, along with some interesting facts about one of the most exciting scientists who ever
lived.
Intro to Isaac -- the program
This program is a simulation that shows you how objects move in space where there is no gravity
or friction. When you run the program, the screen will show a dot. Press any arrow key to apply a force to the
dot, causing the dot to move. It will coast on its own until you apply another force causing it to change its direction
or speed. Here are some things you may wish to try when you run Intro to Isaac:
Run the Intro to Isaac program.
After you've finished running the program, press the Esc key to stop and return to this page.
See how it runs -- the flowchart
This diagram is a flowchart. I use drawings like these to design and write computer software because
they help me keep track of what the computer is doing when the program runs.
After the program starts, it continues getting input from the keyboard, computing the new position of the dot, printing the position and velocity information on the screen, moving the dot to the new position, and then returning to the keyboard again. A series of steps that repeat like this is called a program loop. You can see loops like this easily in the flowchart by following the arrow back to the Input Direction box.
This flowchart diagram would be a great deal more complicated if I tried to include every step in the program. In fact, each of these boxes in the flowchart actually represents several separate computer instructions. The point is to keep flowcharts simple, like an outline, and to use diagrams like this to show how the main ideas interact.
If you would like more basic information about flowcharts and how we use them, check out Flowcharts - a computer roadmap. This option will show you another example of a computer program and explain its flowchart in detail.
You can learn about this program in more detail below. But first, I would like to tell you a few things about Sir Isaac Newton.
About Sir Isaac Newton
The reason that moving the dot in our computer simulation feels funny at first is that we are used to living in a world where friction and gravity are always affecting the way objects behave. When you give something like a small wagon a push, it may move for some distance before it gradually slows down and stops. You know by watching astronauts on TV and maybe seeing Tom Hanks in Apollo 13 that if the same wagon were in a space capsule, it would act differently. Give the weightless wagon a push and it doesn't stop moving all by itself. It coasts, like our dot, until it hits something like the wall of the capsule or an astronaut who failed to duck in time.
Sir Isaac Newton didn't have a handy astronaut or my computer simulation to show him how weightless objects act. Even so, he was able to imagine how objects would move without friction or gravity. This new way of seeing the world gave him a different vision. Unlike Aristotle and others who had thought about these things, Newton now knew that everything moved in relation to forces acting on it, and that friction and gravity were simply two of the forces that can affect the way things move.
An object at rest stays at rest, and an object in motion
stays in motion,
until acted on by some outside force. --- Sir Isaac Newton
Because of Newton and his vision, people began seeing the world and objects in it in a different way. This clearer picture of the universe is an integral part of what we now call physics.
That stupid apple story again
You may have heard the story that Isaac Newton "discovered" gravity when an apple fell and hit him on the head. This is really silly. You don't have to discover gravity because it is a force we all live with from the moment we are born. What Newton discovered was actually inspired by seeing an apple fall from a tree, but his observation is a lot more significant than noticing which way is down.
In his notes, Newton mentions seeing an apple fall while he was in a "contemplative mood."
He realized for the first time that the reason objects do that is because they are attracted to each other. In
other words, there is more to gravity than just "up" and "down." What he actually saw in his
mind that was so fascinating is that the apple and the earth were drawn together. Not only did he see the apple
fall towards the earth; he also saw the earth fall towards the apple.
Before you think this sounds totally weird, realize that the amount the apple fell or moved depends on how massive the earth is, and the amount the earth moved depends on the mass of the apple. There's no contest here. The earth wins by a lot, which is why we see apples, bricks, and other things that aren't tied down or supported falling down, and we don't normally see the planet falling up to meet them.
Creativity is seeing things that everyone else has seen,
and then thinking things that no one else has thought.
--- quoted by Linda Ellerbee
For Newton and other visionaries, seeing is more than just looking at what is obvious and noticing what is obvious. Seeing, in this case, involves an inner vision that all of us have, at least some of the time. The insight that Newton gained while watching an apple fall was central to his understanding how gravity affects everything: you, me, apples, earth, and the entire universe. Because of this vision, he was the first person ever to understand how gravity holds the earth in orbit around the sun. He knew exactly why baseballs curve towards the ground when they are thrown. He even understood how to get from here to the moon as soon as somebody else would invent a rocket big enough.
Before you continue, decide what you would like to do next. Since this is a hypertext seminar and not a book, you can go wherever you want.
Enough already? If you've seen enough about this subject, jump to Back to the start, pick another program to explore, and see something else your computer can do. You can always come back here later if you decide you want more information about Intro to Isaac.
Want to see more technical stuff about this program? Coming up next. Just scroll down and see the Inside look, More ideas, and the Programmer's Toolkit sections below.
Inside look
The box in the flowchart that simply says "Compute position" represents several programming
steps. It is in this step in the program that I add the laws of physics that make the dot on your screen act like
an object in space. Both the horizontal (X) and vertical (Y) directions are computed separately.
Here are the actual steps:
Add acceleration to velocity Vx=Vx+Ax and Vy=Vy+Ay
Add velocity to position x=x+Vx and y=y+Vy
Erase the old dot
Draw the new dot
Add acceleration to velocity Vx=Vx+Ax and Vy=Vy+Ay
Add velocity to position x=x+Vx and y=y+Vy
Erase the old dot
Draw the new dot
The actual code that the computer sees is shown below. The computer instructions are on the left. The comments are on the right. All instructions that begin with a single quote mark are added for my benefit and are ignored by the computer. It is important to add comments like these when you are writing a computer program because it's easy to forget exactly what it was that the computer is supposed to do at each point.
Vx = Vx + Ax 'update velocity
Vy = Vy + Ay
GOSUB PrintStats
IF Vx <> 0 OR Vy <> 0 THEN 'was velocity changed?
DrawSquare x, y, 0 'erase the old square
PSET (oldx, oldy), 11 'leave a trail of dots
oldx = x
oldy = y
x = x + Vx 'add velocity, update position
y = y + Vy
DrawSquare x, y, 11 'draw the new square
END IF
Delay .2 'cool it for 0.2 second
More ideas
There are always more ideas, and I have never created a computer program that I couldn't have added something to that would make it somehow better or more interesting. The trick is knowing when to quit, and I decided that a simple explanation that you could easily see and understand would be better than something more elaborate.
You, of course, don't have to be satisfied with what I've written here. If you like, you could improve this program and replace my flying dot with a much better drawing of a space capsule, floating banana, or whatever. I was tempted to continue working on this program and simulate an actual Apollo spacecraft with all 13 controlling jets in three dimensions with live sound and... Well, you get the idea.
This is a seminar about computers -- not competition with NASA simulators. It is interesting to know, however, that both this simulation and the real stuff the astronauts use are controlled by the same physical laws. And NASA's computer programs as well as mine use equations that tell the computer how to move objects in response to these laws.
Your ideas, improvements, and suggestions are always interesting to me. To drop me a note at ainsworth@qwerty.com. Before you send me any code or specific suggestions, however, please also read my copyright info.
Programmer's toolkit
One of the reasons I like programming in various versions of BASIC
is that it is easy to add your own words to the language. This means that you
can make up a word to do something, and then use it over and over again in many
programs. Three words, called SUBs, are used in this program and are contained
in the program TOOLKIT1.BAS. Once you add these subs to your software, you will
automatically add these words to any BASIC program you write. For more information
on using the toolkit, see Using the Toolkit.
Here are the subs I used in writing ISAAC.BAS:
DrawSquare (x, y, c)
This sub is used in ISAAC and the next two programs. It's a handy way to draw a 3 x 3 square anywhere on the screen. All you have to specify are the coordinates and the color; the sub does the rest. You can also erase a square by drawing it in the background color.
The command PSET colors an individual dot, called a pixel, on the computer screen. In this SUB, a square of nine pixels (3 x 3) is drawn at a particular location, specified by x and y.
SUB DrawSquare (x, y, c)
'draw a 3 x 3 square around the coordinates x, y...
PSET (x, y), c
PSET STEP(-1, -1), c
PSET STEP(1, 0), c
PSET STEP(1, 0), c
PSET STEP(0, 1), c
PSET STEP(0, 1), c
PSET STEP(-1, 0), c
PSET STEP(-1, 0), c
PSET STEP(0, -1), c
END SUB
Delay(Time!)
It's very handy to be able to insert a brief pause at various places in a program. Without a delay, the ISAAC program would run much too fast and be impossible to control. You can always add a delay by giving the computer something useless to do, like counting to a thousand. The problem with this solution is that computers run at different speeds. As soon as someone runs your program on a really fast computer, your program will go too fast. If they try it on an older machine, your program will run like molasses in December.
A better solution is to use the computer's clock to create a short pause. By using the Delay(Time!) sub, this is very easy to do. For a one-second delay, just add the instruction Delay 1 wherever you want the pause. You can even request delays like 1.2 seconds, but the computer's clock is not accurate enough to be really precise with very small numbers.
SUB Delay (Time!)
'wait for (Time!) seconds before proceeding...
Waiter! = TIMER 'get the computer clock (seconds since midnight)
DO
IF TIMER > Waiter! + Time! THEN EXIT DO 'done yet?
LOOP
END SUB
Gobble
Gobble is a sub that I use that gets keys from the keyboard. It automatically clears the keyboard of any keys that have already been pressed. This keeps the program from jumping ahead if the user presses too many keys at once or presses a key before you ask for it.
You may have seen this problem in programs that don't clear the keyboard before getting an input. The program can jump ahead before you expect it to, or it can sit and churn while it tries to digest several keystrokes before continuing. In either case, it is frustrating to use.
The solution is simple. Just add Gobble to your programs before you ask for an input from the keyboard. Your programs will then run clean, without surprises.
SUB Gobble
'eat any keys left in the keyboard buffer
DO
K$ = INKEY$
LOOP WHILE K$ <> ""
END SUB