P PatrikL Member Licensed User Apr 29, 2007 #1 This sub is usable in GPS programs - B4X: Sub Calc result.Text = sqrt(69.1 * (Lat2.Text - Lat1.Text) * 69.1 * (Lat2.Text - Lat1.Text) + 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3) * 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3)) End Sub (Source: http://www.meridianworlddata.com/Distance-Calculation.asp ) - create 5x TextBox - Lat1,2; Lon1,2; result and one Button - Calc My sample is here: Attachments gpsdistance.zip 109.1 KB · Views: 412 Last edited: Apr 29, 2007
This sub is usable in GPS programs - B4X: Sub Calc result.Text = sqrt(69.1 * (Lat2.Text - Lat1.Text) * 69.1 * (Lat2.Text - Lat1.Text) + 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3) * 69.1 * (Lon2.Text - Lon1.Text) * cos(lat1.Text/57.3)) End Sub (Source: http://www.meridianworlddata.com/Distance-Calculation.asp ) - create 5x TextBox - Lat1,2; Lon1,2; result and one Button - Calc My sample is here:
S sho431 New Member Apr 29, 2007 #2 Hi PatrikL very good sample, but what about the direction. Thanks shooshan
S sho431 New Member Apr 30, 2007 #4 PatrikL said: Good idea, i try to find formula via google Click to expand... I need :sign0085: B4X: distanceEast=(Lon2.Text - Lon1.Text) distanceNorth=(Lat2.Text - Lat1.Text) direction= Atan(distanceNorth/distanceEast) Mod (2 * cPI) direction = (direction)*(180/cPI) If direction < 0 Then direction+= 360 End If
PatrikL said: Good idea, i try to find formula via google Click to expand... I need :sign0085: B4X: distanceEast=(Lon2.Text - Lon1.Text) distanceNorth=(Lat2.Text - Lat1.Text) direction= Atan(distanceNorth/distanceEast) Mod (2 * cPI) direction = (direction)*(180/cPI) If direction < 0 Then direction+= 360 End If
Erel B4X founder Staff member Licensed User Longtime User Apr 30, 2007 #5 There is no += in Basic4ppc.
P PatrikL Member Licensed User Apr 30, 2007 #6 2 sho431 - i try repair that sub, but it don't work :sign0085: From where is that formula?