Displaying 1 result from an estimated 1 matches for "pol2car".
2013 Mar 05
2
Function completely locks up my computer if the input is too big
...compass2polar <- function(x) {-x+90}
#degrees (polar) to radians
Deg2Rad <- function(x) {(x*pi)/180}
# radians to degrees
Rad2Deg <- function (rad) (rad/pi)*180
# polar to cartesian coordinates - assumes degrees those from a compass.
output is a list, x & y of equal length
Pol2Car <- function(distance,deg) {
rad <- Deg2Rad(compass2polar(deg))
rad <- rep(rad, length(distance))
x <- ifelse(is.na(distance), NA, distance * cos(rad))
y <- ifelse(is.na(distance), NA, distance * sin(rad))
x<-round(x,2)
y<-round(y,2)
cartes<- list(x,y)
name<-c(...