diff --git a/bin/gnss_simulator.rb b/bin/gnss_simulator.rb index c8e57fe..637eec7 100755 --- a/bin/gnss_simulator.rb +++ b/bin/gnss_simulator.rb @@ -45,9 +45,10 @@ loop do angle = (elapsed / LOOP_SECONDS) * 2 * Math::PI lat, lon = point_on_loop(LAT, LON, RADIUS_M, angle) - # Bearing of travel: tangent to the circle, 90 degrees ahead of the - # radius vector at this point. - track = (angle * 180 / Math::PI + 90) % 360 + # Bearing of travel (compass: 0 = north, clockwise). The loop runs + # counterclockwise from east (angle is a math angle), so the velocity + # points (east, north) = (-sin, cos): bearing atan2(-sin, cos) = -angle. + track = (-angle * 180 / Math::PI) % 360 speed = (2 * Math::PI * RADIUS_M) / LOOP_SECONDS # m/s, constant pace report = {