How to resolve the algorithm Haversine formula step by step in the Oforth programming language
How to resolve the algorithm Haversine formula step by step in the Oforth 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 Oforth programming language
Source code in the oforth programming language
import: math
: haversine(lat1, lon1, lat2, lon2)
| lat lon |
lat2 lat1 - asRadian ->lat
lon2 lon1 - asRadian ->lon
lon 2 / sin sq lat1 asRadian cos * lat2 asRadian cos *
lat 2 / sin sq + sqrt asin 2 * 6372.8 * ;
haversine(36.12, -86.67, 33.94, -118.40) println
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the PHP programming language
You may also check:How to resolve the algorithm QR decomposition step by step in the Wren programming language
You may also check:How to resolve the algorithm Pangram checker step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bogosort step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Bioinformatics/Sequence mutation step by step in the J programming language