Hi all,

I'm facing a problem, wich I do not understand.

I need to find the angle between 2 points . The ideia is to detect turns above a certain angle during motion.

I have this little piece of code in GPS_LocationChanged (there is more code there, but is not relevant to this problem).

PointC_lat & pointC_long hold the coordinates of the previous detected point.

pontoA_long, PontoA_lat, PontoC_long and PontoC_lat are all global variables.

The distance between the points is small, between 30 to 300 meters, depending on speed.

First of all the value never stays put. Even with the device on a stable surface the value keeps changing in almost a random way. (it can be -146, 10,64,-110, or whatever)

Second it does not correlate in any form with the angle of movement if I actualy start moving around to test,

I also tryed with bearing to...but no luck in getting the angle.

Anyone there to help me out understanding this behaviour ?

Many thanks

JM

I'm facing a problem, wich I do not understand.

I need to find the angle between 2 points . The ideia is to detect turns above a certain angle during motion.

I have this little piece of code in GPS_LocationChanged (there is more code there, but is not relevant to this problem).

PointC_lat & pointC_long hold the coordinates of the previous detected point.

pontoA_long, PontoA_lat, PontoC_long and PontoC_lat are all global variables.

The distance between the points is small, between 30 to 300 meters, depending on speed.

B4X:

```
GPS_LocationChanged (Location1 As Location)
pontoA_lat=Location1.Latitude
pontoA_long=Location1.Longitude
Private y As Float
Private x As Float
Private angulo As Float
y=(pontoA_lat-pontoC_lat)
x=Cos(cPI/180*pontoC_lat)*(pontoA_long-pontoC_long)
angulo=ATan2(y,x)
Label5.Text=Round2(angulo*(180/cPI),1)
end sub
```

First of all the value never stays put. Even with the device on a stable surface the value keeps changing in almost a random way. (it can be -146, 10,64,-110, or whatever)

Second it does not correlate in any form with the angle of movement if I actualy start moving around to test,

I also tryed with bearing to...but no luck in getting the angle.

Anyone there to help me out understanding this behaviour ?

Many thanks

JM

Last edited: