R/sl.xyz2lonlat.R

Defines functions sl.xyz2lonlat

Documented in sl.xyz2lonlat

sl.xyz2lonlat <-
function(xyzvec) {
	if (length(xyzvec) != 3) {stop("xyzvec must be a cartesian vector of length 3!")}
	xyzvec = xyzvec / sl.cart.dist(xyzvec)
	rad = pi / 180
	lon = atan2(xyzvec[2],xyzvec[1]) / rad
	lat = asin(xyzvec[3]) / rad
	return(c(lon,lat))
}
helgegoessling/spheRlab documentation built on Sept. 10, 2018, 12:50 a.m.