Here’s my comments on adjusting bearing…

And I’ll share some simple code for how to do this type of translation with latitude and longitude here:

Bearing:

```
public double getBearingTo(Position position) {
final double dLon = Math.toRadians(position.getLongitude() - longitude);
final double y = Math.sin(dLon) * Math.cos(Math.toRadians(position.getLatitude()));
final double x = Math.cos(Math.toRadians(latitude)) *
Math.sin(Math.toRadians(position.getLatitude())) - Math.sin(Math.toRadians(latitude)) *
Math.cos(Math.toRadians(position.getLatitude())) * Math.cos(dLon);
final double bearing = Math.atan2(y, x);
return (Math.toDegrees(bearing) + 360) % 360;
}
```

Distance:

```
public double getDistanceTo(final Position position, final boolean withLoiter) {
if (position == null) return Double.MAX_VALUE;
// pythagorean theorem
final double dist = Math.sqrt(
Math.pow(Math.toRadians(position.getLatitude()) - Math.toRadians(latitude), 2) +
Math.pow(Math.toRadians(position.getLongitude()) - Math.toRadians(longitude), 2)
);
// return distance in meters
final double distance = EARTH_RADIUS_METERS * dist - (withLoiter ? loiteringDistance : 0);
return distance > 0 ? distance : 0;
}
```

Angle of attack:

```
public int getAngleTo(Position position) {
if (position == null) return Integer.MAX_VALUE;
final double opposite = altitude;
final double adjacent = getDistanceTo(position, false);
return (int) Math.toDegrees(Math.atan2(opposite > 0 ? opposite : 0, adjacent > 0 ? adjacent : 0));
}
```