Open casa-henrym opened 3 years ago
The same issue as raised previously - an attempt to calculate acos() of a number (slightly) greater than 1 and (slightly) less than -1:
dput((sin(lat2) - sin(lat1) * cos(dist12))/(sin(dist12) * cos(lat1)))
dput((sin(lat1) - sin(lat2) * cos(dist12))/(sin(dist12) * cos(lat2)))
My work-around:
... i <- rep(TRUE, length(dist12)) i[dist12 == 0] <- FALSE foo <- (sin(lat2) - sin(lat1) * cos(dist12))/(sin(dist12) * cos(lat1)) foo[foo > 1] <- 1 foo[foo < -1] <- -1 brngA <- acos(foo) brngA[is.na(brngA)] <- 0 bar <- (sin(lat1) - sin(lat2) * cos(dist12))/(sin(dist12) * cos(lat2)) bar[bar > 1] <- 1 bar[bar < -1] <- -1 brngB <- acos(bar) g <- (sin(lon2 - lon1) > 0) ...
The same issue as raised previously - an attempt to calculate acos() of a number (slightly) greater than 1 and (slightly) less than -1:
dput((sin(lat2) - sin(lat1) * cos(dist12))/(sin(dist12) * cos(lat1)))
dput((sin(lat1) - sin(lat2) * cos(dist12))/(sin(dist12) * cos(lat2)))
My work-around: