September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
30
Task/Haversine-formula/TechBASIC/haversine-formula.techbasic
Normal file
30
Task/Haversine-formula/TechBASIC/haversine-formula.techbasic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
FUNCTION HAVERSINE
|
||||
!---------------------------------------------------------------
|
||||
!*** Haversine Formula - Calculate distances by LAT/LONG
|
||||
!
|
||||
|
||||
!*** LAT/LON of the two locations and Unit of measure are GLOBAL
|
||||
!*** as they are defined in the main logic of the program, so they
|
||||
!*** available for use in the Function.
|
||||
!*** Usage: X=HAVERSINE
|
||||
|
||||
|
||||
Radius=6378.137
|
||||
Lat1=(Lat1*MATH.PI/180)
|
||||
Lon1=(Lon1*MATH.PI/180)
|
||||
Lat2=(Lat2*MATH.PI/180)
|
||||
Lon2=(Lon2*MATH.PI/180)
|
||||
DLon=Lon1-Lon2
|
||||
ANSWER=ACOS(SIN(Lat1)*SIN(Lat2)+COS(Lat1)*COS(Lat2)*COS(DLon))*Radius
|
||||
|
||||
DISTANCE="kilometers"
|
||||
SELECT CASE UNIT
|
||||
CASE "M"
|
||||
HAVERSINE=ANSWER*0.621371192
|
||||
Distance="miles"
|
||||
CASE "N"
|
||||
HAVERSINE=ANSWER*0.539956803
|
||||
Distance="nautical miles"
|
||||
END SELECT
|
||||
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue