This is only a preview of the February 1990 issue of Silicon Chip. You can view 51 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
|
Computer program calculates
great circle bearings & distances
If you want to point your beam to Recife on the
eastern-most tip of Brazil, what bearing would you
use? A map based on Mercator's projection would
suggest a few degrees north of east but of course
you know better than that.
By PHILIP WATSON, VK2ZPW
But what bearing would you use?
If you are lucky enough to have a
great circle map based on your city,
that's fine. But if not, or you live
somewhere between Woop Woop
and Bulamakanka, finding the correct bearing is not always easy.
This program will calculate the
distance and bearing between any
two points on earth. All you have to
do is feed in the latitude and
longitude of each. It was written by
J. Hall and C. Hutchinson of ARRL
headquarters and published in
several editions of the ARRL Antenna Book. The ARRL has waived any
copyright restrictions on the program.
The program was originally written for a Radio Shack TRS-80 Level
II computer using a form of BASIC
suited to that machine. This differs
slightly from GW BASIC and the
version given here has been
modified to suit the latter.
Also, the original was written to
accept degrees and decimals of a
degree. Since most references
quote degrees and minutes, the program has been modified to accept
data in this form.
Another modification has been to
write the user's location permanently into the program. This is
shown at line 260 which lists the
location for Sydney. All you have to
do is substitute your own location
and the corresponding latitude and
longitude figures where appropriate.
The most practical way to use the
program is to compile a list of major
world centres, plus any special
localities the you frequently contact. This can be kept at the
operating position.
Using the software is easy. First
boot up your computer in GW
BASIC, then load and run the program in the usual manner. Fig.2
shows the program listing while
Fig.1 shows a sample readout. You
simply enter the name of the distant
location, the latitude and longitude
of your own location, and the
latitute and longitude of the distant
location. The program then displays
the required information and asks
Sample Printout
PROGRAM TO CALCULATE GREAT CIRCLE DISTANCES~ BEARINGS
BY J. HALL~ C HUTCHINSON, ARRL HQ, JULY 1981
ARRL PROGRAM IS NOT COPYRIGHTED~ MAY BE REPRODUCED FREELY
<MODIFIED BY P. WATSON, VK2ZPW>
ENTER NEGATIVE VALUES FOR LATITUDES SOUTH OF THE EQUATOR
ENTER NEGATIVE VALUES FOR LONGITUDES EAST OF GREENWICH <MAX 180)
SYDNEY:LAT.-33DEG.55MIN. LON.-151DEG.13MIN.
ENTER NAME OF DISTANT LOCATION (OPTIONAL) SAN FRANCISCO
THIS LOCATION LATITUDE (DEGREES AND MINUTES)? -33.55
THIS LOCATION LONGITUDE <DEGREES AND MINUTES)? -152.13
OTHER LOCATION LATITUDE (DEGREES AND MINUTES>? 37.45
OTHER LOCATION LONGITUDE (DEGREES AND MINUTES>? 122.27
DISTANT LOCALITY: SAN FRANCISCO
THE FORWARD BEARING IS
55.385 DEGREES
THE GREAT CIRCLE DISTANCE IS
11861.15 KILOMETRES
6405.08 NAUTICAL MILES
7370.22 STATUTE MILES
TO CALCULATE NEW BEARING PRESS ENTER?
Fig.1: this sample printout shows the hearing and distance from Sydney to San Francisco, USA. You
simply enter in the latitude and longitude of each location.
78
SILICON CHIP
Program Listing
10 REM*** BEARING/BAS***
20 REM A=YOUR LAT.
30 REM B=OTHER STATION LAT.
40 REM C=BEARING ANGLE
50 REM D=DEGREES OF ARC
60 REM E=INTERMEDIATE VALUE
70 REM K=CONVERSION CONSTANT,ARC TO KILOMETRES
80 REM L=DIFF IN LONGITUDES
90 REM Ll=YOUR LONG
100 REM L2=0THER STATION LONG
110 REM M=CONVERSION CONSTANT, DEGREES TO RADIANS
120 REM N=CONVERSION CONST, ARC TO NAUT MI.
130 REM S=CONVERSION CONST, ARC TO STATUTE MI.
140 CLS:KEY OFF
150 PRINT"PROGRAM TO CALCULATE GREAT CIRCLE DISTANCES~ BEARINGS"
160 PRINT
170 PRINT"BY J. HALL~ C HUTCHINSON, ARRL HQ, JULY 1981
180 PRINT"ARRL PROGRAM IS NOT COPYRIGHTED~ MAY BE REPRODUCED FREELY "
185 PRINT"(MODIFIED BY P. WATSON, VK2ZPW>"
190 DEFDBL A,A,C,D,E,L,M:
200 D=1:K=111.11:M=57.29577951308238#:N=60:S=69.041:
210 PRINT
220 PRINT"ENTER NEGATIVE VALUES FOR LATITUDES SOUTH OF THE EQUATOR"
230 PRINT"ENTER NEGATIVE VALUES FOR LONGITUDES EAST OF GREENWICH <MAX 180)"
240 IF D<>l THEN 320
250 PRINT
260 PRINT"SYDNEY:LAT.-33DEG.55MIN. LON.-151DEG.13MIN."
270 INPUT"ENTER NAME OF DISTANT LOCATION (OPTIONAL> ", N$
280 INPUT"THIS·LOCATION LATITUD£ (DEGREES AND MINUTES>";A:
290 A1=(A-FIX<A>>:A2=A-A1:A=A2+(A1/,6):A=A/M
300 INPUT"THIS LOCATION LONGITUDE (DEGREES AND MINUTES>";Lt
310 L11=(L1-FIX(L1)):L12=L1-L11:L1=L12+(L11/.6):
320 INPUT"OTHER LOCATION LATITUDE (DEGREES AND MINUTES>";B:
330 B1=(B-FIX<B>>:B2=B-B1:B=B2+(B1/.6):B=B/M
340 INPUT"OTHER LOCATION LONGITUDE (DEGREES AND MINUTES)";L2
350 L21=(L2-FIX<L2)):L22=L2-L21:L2=L22+(L21/,6):
360 L=!L1-L2>/M
370 E=SIN<A>*SIN!B)+COS(A>*COS<B>*COS<L>
380 D=-ATNCE/SQR(l-E*E))+!.57079
390 C=(SIN(B)-SIN<A>*E)/(COS(A)*SIN(D>>
400 IF C>=l THEN C=O:GOTO 420ELSE IF C<=-1 THEN C=180/M:GOT0310
410 C=-ATN(C/SQR(l-C*C>)+!.57079
420 C=C*M
430 IF SIN(L><O THEN C=360-C
440 PRINT"DISTANT LOCALITY: "JN$
450 PRINT "THE FORWARD BEARING IS";:PRINT TAB(36)USING"#####,###";C ;
455 PRINT" DEGREES"
460 PRINT"THE GREAT CIRCLE DISTANCE IS";
470 PRINT TAB(35)USING"######.##";K*D*M;:PRINT" KILOMETRES"
480 PRINT TAB(35)USING"######.##";N*D*M;:PRINT" NAUTICAL MILES"
490 PRINT TAB<35)USING"######.##";S*D*M;:PRINT" STATUTE MILES":PRINT
500 INPUT"TO CALCULATE NEW BEARING PRESS ENTER ";D:GOTO 260:
Fig.2: the program is written is GWBASIC but conversion to other BASICs should pose no problem. Note
that you will have to customise line 260 to suit your particular location.
if you want to calculate another
bearing.
To exit the program, you simply
hit Ctrl Break. You can then exit to
DOS by typing SYSTEM and pressing
the Enter key
And the bearing for Recife'? Oh
yes - around 170 degrees, or over
Antartica, close to the South Pole.~
FEBRUARY1990
79
|