bearingTo method
- RaliPosition other
Calculate bearing to another position in degrees
Implementation
double bearingTo(RaliPosition other) {
final startLat = _toRadians(lat);
final startLng = _toRadians(lng);
final destLat = _toRadians(other.lat);
final destLng = _toRadians(other.lng);
final y = math.sin(destLng - startLng) * math.cos(destLat);
final x = math.cos(startLat) * math.sin(destLat) -
math.sin(startLat) * math.cos(destLat) * math.cos(destLng - startLng);
final bearingRad = math.atan2(y, x);
final bearingDeg = _toDegrees(bearingRad);
return (bearingDeg + 360) % 360; // Normalize to 0-360
}