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?
Based on the answer of @clody96 and @mike, here is an implementation in R using a data.frame with velocity and timesteps instead of distance:
points = data.frame(
lon = seq(11, 30, 1),
lat = seq(50, 59.5, 0.5),
bea = rep(270, 20),
time = rep(60,20),
vel = runif(20,1000, 3000)
)
## lat, lng in degrees. Bearing in degrees. Distance in m
calcPosBear = function(df) {
earthR = 6371000;
## Units meter, seconds and meter/seconds
df$dist = df$time * df$vel
lat2 = asin(sin(
pi / 180 * df$lat) *
cos(df$dist / earthR) +
cos(pi / 180 * df$lat) *
sin(df$dist / earthR) *
cos(pi / 180 * df$bea));
lon2 = pi / 180 * df$lon +
atan2(sin( pi / 180 * df$bea) *
sin(df$dist / earthR) *
cos( pi / 180 * df$lat ),
cos(df$dist / earthR) -
sin( pi / 180 * df$lat) *
sin(lat2));
df$latR = (180 * lat2) / pi
df$lonR = (180 * lon2) / pi
return(df);
};
df = calcPosBear(points)
plot(df$lon, df$lat)
points(df$lonR, df$latR, col="red")
Which brings the same result as for @clody96:
points = data.frame(
lon = 25,
lat = 60,
bea = 30,
time = 1000,
vel = 1
)
df = calcPosBear(points)
df
lon lat bea time vel dist latR lonR 1 25 60 30 1000 1 1000 60.00778805 25.00899533