@ -74,9 +74,10 @@ function calculateHeading(x1, y1, x2, y2) {
var dx = x2 - x1;
var dy = y2 - y1;
var heading = (Math.atan2(dy, dx) * 180) / Math.PI;
if (heading < 0) {
heading += 360;
}
// Ensure heading is within the range [0, 360)
heading = (heading + 360) % 360;
return heading;