Java Script Code to Calculate Speed / Distance of Falling Object
By Stephen Bucaro
The Greek philosopher Aristotle taught that everything was made of four elements:
air, fire, earth. and water. He taught that lighter objects fall more slowly than
heavier ones because they contain more of the lighter elements, air and fire.
Heavier objects fall faster because they contain more of the heavier elements,
earth and water. Aristotle also taught that an object will stop moving when the
force acting on it is removed.
The Italian scientist Galileo proved that, in the absence of friction, all bodies
accelerate toward the earth with the same rate of acceleration, regardless of their
weight. He also proved that, in the absence of friction, bodies would keep moving forever.
I like to brag about Italian scientists because Iím Italian. In fact, according
to me, almost all discoveries ever made where made by Italians. You throw in Leonardo
da Vinci, Luigi Galvani, Guglielmo Marconi, and Enrico Fermi, and I think I'm pretty
But in reality Aristotle lived between 384 BC and 322 BC, long before the Renaissance.
when science was done by thinking about things, not actually doing experiments. So for
his time, Aristotle was a genius. While Galileo lived between 1564 and 1642, right in
the heart of the Renaissance. The Renaissance, by the way, started in Italy.
The acceleration due to gravity is 32.173 feet per second per second. Using this
value, and the number of seconds an object has been falling, you can calculate how far
it has fallen or how fast the object is moving. In this article, you'll learn how to
use Java Script to create a Gravity Calculator that that does this and much more.
Note: The value of 32.173 ft/s2 is accurate only at sea level at the
equator. Gravity decreases with greater distance from the Earth's center. And since
the earth is not a perfect sphere, it also varies with latitude.
I have programmed many Java Script calculators and discovered that, the process of
coding any calculator can be broken down into a step-by-step procedure. Shown below
are the steps to build a calculator.
1. Acquire the formula
2. Determine the inputs and outputs
3. Design the html form
4. Write Java Script to process the form
5. Test and Final Touches
Step 1: Gravity Formulas
The formula for the acceleration due to gravity is:
g = 32.173 ft/s2 (feet per second squared)
g = 9.8 m/s2 (meters per second squared)
That formula rearranged to calculate distance traveled in time t is:
d = gt2/2
That formula rearranged to calculate time elapsed to fall distance d is:
t = sqrt(2d/g)
You can also calculate the instantaneous velocity of a falling object after elapsed time t:
vi = gt
Or the instantaneous velocity of a falling object that has traveled distance d:
vi = sqrt(2gd)