How to resolve the algorithm Haversine formula step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Haversine formula step by step in the Run BASIC programming language

Table of Contents

Problem Statement

The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes. It is a special case of a more general formula in spherical trigonometry, the law of haversines, relating the sides and angles of spherical "triangles".

Implement a great-circle distance function, or use a library function, to show the great-circle distance between:

Most of the examples below adopted Kaimbridge's recommended value of 6372.8 km for the earth radius. However, the derivation of this ellipsoidal quadratic mean radius is wrong (the averaging over azimuth is biased). When applying these examples in real applications, it is better to use the mean earth radius, 6371 km. This value is recommended by the International Union of Geodesy and Geophysics and it minimizes the RMS relative error between the great circle and geodesic distance.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Haversine formula step by step in the Run BASIC programming language

Source code in the run programming language

    D2R = atn(1)/45
    diam  = 2 * 6372.8
Lg1m2  = ((-86.67)-(-118.4)) * D2R
Lt1    = 36.12 * D2R ' degrees to rad
Lt2    = 33.94 * D2R
    dz    = sin(Lt1) - sin(Lt2)
    dx    = cos(Lg1m2) * cos(Lt1) - cos(Lt2)
    dy    = sin(Lg1m2) * cos(Lt1)
    hDist = asn((dx^2 + dy^2 + dz^2)^0.5 /2) * diam
print "Haversine distance: ";using("####.#############",hDist);" km."

 'Tips: ( 36 deg 7 min 12 sec ) = print 36+(7/60)+(12/3600).  Produces: 36.12 deg.
 '
 '      http://maps.google.com
 '      Search   36.12,-86.67
 '      Earth.
 '      Center the pin, zoom airport.
 '      Directions (destination).
 '      36.12.-86.66999
 '      Distance is 35.37 inches.

  

You may also check:How to resolve the algorithm Minimum positive multiple in base 10 using only 0 and 1 step by step in the Wren programming language
You may also check:How to resolve the algorithm Loops/Downward for step by step in the Draco programming language
You may also check:How to resolve the algorithm Continued fraction step by step in the 11l programming language
You may also check:How to resolve the algorithm Set consolidation step by step in the Scala programming language
You may also check:How to resolve the algorithm Call a foreign-language function step by step in the zkl programming language