GNSS course worked out server-side (App.gnss_update, for the CAN node and the simulation, which send none): following in 3D turns heading-up behind the position again
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-30 18:45:32 +01:00
1 parent f65eb98d18
commit 8680cdbee7
4 files changed
+62 -6

No files matched your search

+9
View File
@@ -93,6 +93,15 @@ module Maptool
raise Routing::RouteError, "no route from #{position.map { |v| v.round(5) }.join(', ')}: #{last&.message}"
end
# Initial bearing from one [lon, lat] to another, 0..360° from north.
def self.bearing((lon1, lat1), (lon2, lat2))
rad = Math::PI / 180
d = (lon2 - lon1) * rad
y = Math.sin(d) * Math.cos(lat2 * rad)
x = Math.cos(lat1 * rad) * Math.sin(lat2 * rad) - Math.sin(lat1 * rad) * Math.cos(lat2 * rad) * Math.cos(d)
(Math.atan2(y, x) / rad) % 360
end
def self.meters((lon1, lat1), (lon2, lat2))
Math.hypot((lon2 - lon1) * Math.cos((lat1 + lat2) / 2 * Math::PI / 180), lat2 - lat1) * 111_320
end