CITS2002 Systems Programming | |
|
Workshop 3: Functions, parameter passing, and structures
BEFORE this workshop session,
you're strongly encouraged to think how you would do it.
You are not expected to have developed and tested a perfect solution before
the workshop,
but you should at least scratch out your approach on paper.
In this workshop we'll develop a small number of functions to determine the distance between two points on the Earth's surface. We'll first develop a command-line utility, named haversine, that accepts a pair of points on the Earth's surface and determines the distance between the two points: prompt> ./haversine -31.977537 115.816451 -31.982842 115.818725 627metres We'll next develop a utility, named haversine2, that accepts an arbitrary number of latitude and longitude pairs, and determines the distance between the first and last points (by following a route): prompt> ./haversine2 \ -31.977537 115.816451 -31.977632 115.816871 \ -31.977616 115.817170 -31.980981 115.817174 \ -31.980975 115.818709 -31.982842 115.818725 796metres
There are number of formulae that perform this calculation,
some accounting for the fact that the Earth is not a true sphere.
NOTE - this workshop is not requiring us to understand the formula, just to implement it in C11. Do not be alarmed by the use of spherical trigonometry (it won't be in the exam!) The haversine function was used in the CIT2002 1st project from 2015. Our goal is to:
to develop 3 simple functions:
and to use them, in combination, to calculate the distance between the
Computer Science building
and the
BEFORE the workshop session, you're strongly encouraged to think how you would do it. You are not expected to have developed and tested a perfect solution before the workshop, but you should at least scratch out your approach on paper. From the information presented in lectures so far, we know:
And a great article on very early attempts to calculate the Earth's radius: https://www.abc.net.au/.../eratosthenes-measured-circumference-of-the-earth-2200-years-ago.
|