computeOffset static method
Returns the Point resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north).
from
The Point from which to start.
distance
The distance to travel.
heading
The heading in degrees clockwise from north.
Implementation
static Point computeOffset(Point from, num distance, num heading) {
distance /= MathUtils.earthRadius;
heading = toRadians(heading);
// http://williams.best.vwh.net/avform.htm#LL
num fromLat = toRadians(from.x);
num fromLng = toRadians(from.y);
num cosDistance = cos(distance);
num sinDistance = sin(distance);
num sinFromLat = sin(fromLat);
num cosFromLat = cos(fromLat);
num sinLat =
cosDistance * sinFromLat + sinDistance * cosFromLat * cos(heading);
num dLng = atan2(sinDistance * cosFromLat * sin(heading),
cosDistance - sinFromLat * sinLat);
return Point(toDegrees(asin(sinLat)), toDegrees(fromLng + dLng));
}