I have know my current position({lat:x,lon:y}) and I know my speed and direction angle; How to predict next position at next time?
Same code in Java:
final double r = 6371 * 1000; // Earth Radius in m
double lat2 = Math.asin(Math.sin(Math.toRadians(lat)) * Math.cos(distance / r)
+ Math.cos(Math.toRadians(lat)) * Math.sin(distance / r) * Math.cos(Math.toRadians(bearing)));
double lon2 = Math.toRadians(lon)
+ Math.atan2(Math.sin(Math.toRadians(bearing)) * Math.sin(distance / r) * Math.cos(Math.toRadians(lat)), Math.cos(distance / r)
- Math.sin(Math.toRadians(lat)) * Math.sin(lat2));
lat2 = Math.toDegrees( lat2);
lon2 = Math.toDegrees(lon2);