Implementation
static FlightLocation vectorToLocation(
{required FlightLocation droneLocation,
required FlightLocation pointOfInterest,
required FlightVector vector}) {
final double azimuthToDestination;
final double destinationLatitude;
final double destinationLongitude;
azimuthToDestination = 180 -
vector.headingRelativeToPointOfInterest -
(atan((droneLocation.latitude - pointOfInterest.latitude).abs() /
(droneLocation.longitude - pointOfInterest.longitude).abs()) *
180 /
pi);
// Latitude = North/South
destinationLatitude = pointOfInterest.latitude +
(vector.distanceFromPointOfInterest *
sin(azimuthToDestination * pi / 180) *
meterToDecimalDegree);
// Longitude = East/West
destinationLongitude = pointOfInterest.longitude +
(vector.distanceFromPointOfInterest *
cos(azimuthToDestination * pi / 180) *
meterToDecimalDegree);
return FlightLocation(
latitude: destinationLatitude,
longitude: destinationLongitude,
altitude: vector.destinationAltitude);
}