RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Heading via lua
Author Message
Reply with quote
Post Heading via lua 
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

View user's profile Send private message
Reply with quote
Post  
came accross this post when looking to see if this bridge had been crossed..

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-bearing-or-heading-angle-between-two-points-latitude-longitude/

Code:
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


a lot of math functions to do, not sure how computationally expensive it will be. i'd operate it at a much lower tick rate than the GPS. maybe 10hz instead of 50?

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum