anyone worked out heading via lua?

not sure it's the best place to do it, due to jitter you would have to average out a few readings to calculate it reasonably

## Heading via lua

I've created a function that will give heading angle in degrees.I haven't tested this yet but in theory it should work if Lua is fully implemented.

I got the function from:

https://www.igismap.com/formula-to-find ... longitude/

Code: Select all

```
function headingcalc(lat2,lon2,lat1,lon1)
rlat1 = math.rad(lat1)
rlon1 = math.rad(lon1)
rlat2 = math.rad(lat2)
rlon2 = math.rad(lon2)
dlon = rlon2-rlon1
x = math.cos(rlat2) * math.sin(dlon)
y = math.cos(rlat1) * math.sin (rlat2) - math.sin(rlat1) * math.cos(rlat2) * math.cos(dlon)
rhead = math.atan2(x,y)
return math.deg(rhead)
end
```

### Re: Heading via lua

I'm curious why you wanted to implement this. I may have a similar need with integration with an AEM CD-7 dash.MrBlahh wrote:anyone worked out heading via lua?

not sure it's the best place to do it, due to jitter you would have to average out a few readings to calculate it reasonably