-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
track_intermediate #2
Comments
Now in branch https://github.com/Trackage/traipse/tree/track-intermediate Includes optional date intput, and Suggests-examples in dontrun |
mdsumner
added a commit
that referenced
this issue
Aug 21, 2019
Could be better vectorized like this? This is derived from .vectorize_interm <- function(p1, p2, n) {
stopifnot(nrow(p1) == nrow(p2))
stopifnot(length(n) == 1L || length(n) == nrow(p1))
if (length(n) == 1L) n <- rep(n,nrow(p1))
toRad <- pi / 180
d <- rep(distCosine(p1, p2, r=1), n)
lon1 <- rep(p1[,1] * toRad, n)
lat1 <- rep(p1[,2] * toRad, n)
lon2 <- rep(p2[,1] * toRad, n)
lat2 <- rep(p2[,2] * toRad, n)
n <- pmax(round(n), 1)
## todo this is repeating each point, need to drop each end
f <- unlist(lapply(n, function(nn) seq(0, 1, length.out = nn)))
A <- sin((1-f)*d) / sin(d)
B <- sin(f*d) / sin(d)
x <- A*cos(lat1)*cos(lon1) + B*cos(lat2)*cos(lon2)
y <- A*cos(lat1)*sin(lon1) + B*cos(lat2)*sin(lon2)
z <- A*sin(lat1) + B*sin(lat2)
lat <- atan2(z,sqrt(x^2+y^2))
lon <- atan2(y,x)
cbind(lon,lat)/toRad
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2019-08-20 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: