Hi all,
Im headbreaking over the following case.
I want to know a new lattitude and longitude location.
Parameters given are:
Longitude + Lattitude + Bearing + Distance
I found some code on the internet, but i cant seems to figure out why it is not working..
I get really strange outputs.. :sign0163:
My inputs are in HH.MMSS like 52.3919
Program is attached.
This is my code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			Im headbreaking over the following case.
I want to know a new lattitude and longitude location.
Parameters given are:
Longitude + Lattitude + Bearing + Distance
I found some code on the internet, but i cant seems to figure out why it is not working..
I get really strange outputs.. :sign0163:
My inputs are in HH.MMSS like 52.3919
Program is attached.
This is my code:
			
				B4X:
			
		
		
		'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Lattitude_input As EditText
   Dim Longitude_input As EditText
   Dim Distance_input As EditText
   Dim Bearing_input As EditText
   Dim Calc_button As Button
   Dim LatA, LonA As Double
   Dim LatB, LonB As Double
   Dim Distance, Bearing As Int
   Dim Radius As Int = 6372.795477598
   
   Dim Longitude_output As Label
   Dim lattitude_output As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("Layout1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Calc_button_down
   LatA = Lattitude_input.Text
   LonA = Longitude_input.Text
   Distance = Distance_input.Text
   Bearing = Bearing_input.Text
   
   Distance = (Distance /Radius)
   
   'LatB = ASin(Sin(LatA) * Cos(Distance/Radius) + Cos(LatA) * Sin(Distance/Radius) * Cos(Bearing))
   'LonB = LonA + ATan2(Sin(Bearing) * Sin(Distance / Radius) * Cos(LatA), Cos(Distance / Radius) - Sin(LatA) * Sin(LatB))
   
   LatB =ASin(Sin(LatA)*Cos(Distance/Radius) + Cos(LatA)*Sin(Distance/Radius)*Cos(Bearing))
   LonB = LonA + ATan2(Cos(Distance/Radius)-Sin(LatA)*Sin(LatB), Sin(Bearing)*Sin(Distance/Radius)*Cos(LatA)) 
   
   lattitude_output.Text = ""
   Longitude_output.Text = ""
   lattitude_output.Text = LatB
   Longitude_output.Text = LonB
   
      
End Sub