home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / Recent / dev / amos / Distance2.lzh / Distance2.bas < prev    next >
BASIC Source File  |  2000-10-28  |  1KB  |  40 lines

  1. Set Double Precision 
  2. Def Fn DM#(A#)=((Abs(A#)-Int(Abs(A#)))/60.0*100.0+Int(Abs(A#)))*Sgn(A#)
  3. Rem:New-in-version-2:You-can-enter-points-using-degrees-and-minutes. 
  4. Rem:So-when-you-wish-to-enter-60-degrees-and-30-minutes,just-enter-60.30!
  5.  
  6. Palette $C0,$0
  7. Rem:Good old times style screen
  8. Cls 1 : Pen 0
  9. Rem An Amos program to calculate distance between two points 
  10. Rem on Earth when their latitude and longitude are given.  
  11. Rem:Due to the notorious arithemtics of Amos,this program makes often
  12. Rem:errors from 0-to20km,but it is not my fault,but Amos`.
  13. Rem:Buy a better Basic inter-
  14. Rem:preter/compiler!:-)
  15. RZ$="######"
  16. 10 Degree 
  17. Rem:Because this is very standard basic,this should work in the
  18. Rem:most of Basics,specially in STOS,but I have not tried.
  19. Rem:Only minor changes would needed
  20. R#=6378.15 : Rem Earth radius in kilometers 
  21. Rem:You can change this to miles,so you get the result in miles, too.
  22. Print "Point 1"
  23. Print "Give latitude and longitude (in degrees and minutes , +=North/West, -=South/East) "
  24. Input LA1#,LO1#
  25. LA1#= Fn DM#(LA1#) : LO1#= Fn DM#(LO1#)
  26.  
  27. Print "Point 2"
  28. Print "Give latitude and longitude "
  29. Input LA2#,LO2#
  30. LA2#= Fn DM#(LA2#) : LO2#= Fn DM#(LO2#)
  31. KOSALFA#=Cos(LA1#)*Cos(LO1#)*Cos(LA2#)*Cos(LO2#)+Cos(LA1#)*Sin(LO1#)*Cos(LA2#)*Sin(LO2#)+Sin(LA1#)*Sin(LA2#)
  32. Radian 
  33. ALFA#=Acos(KOSALFA#)
  34. DISTANCEKM#=ALFA#*R#
  35. Print "Distance:";
  36. Print Using RZ$;DISTANCEKM#;" km."
  37. Input "Again (Y/N)";Q$
  38. If Upper$(Q$)="Y" Then Goto 10
  39.  
  40.