sl.lonlat2xyz: Convert Lon-Lat to X-Y-Z

View source: R/sl.lonlat2xyz.R

sl.lonlat2xyzR Documentation

Convert Lon-Lat to X-Y-Z

Description

Covert one or more points from longitude-latitude to x-y-z coordinates on a unit sphere.

Usage

sl.lonlat2xyz(lonlatvec=NULL, lon=NULL, lat=NULL)

Arguments

lonlatvec

a vector of length 2 with the longitude and latitude of a single point, or NULL (default).

lon

a vector or array with the longitudes of one or more points, or NULL (default). Used only if xyzvec=NULL.

lat

a vector or array with the latitudes of one or more points, or NULL (default). Used only if xyzvec=NULL.

Value

If lonlatvec=NULL, a list with elements x, y, and z, each of which are vectors or arrays of the same size as lon,lat with the x-y-z coordinates of the points on the unit sphere. Otherwise, a single vector of length 3 with the x-y-z coordinates of the single point on the unit sphere.

Author(s)

Helge Goessling

See Also

sl.xyz2lonlat

Examples

sl.lonlat2xyz(lonlatvec=c(10,20))
## Should return:
## [1] 0.9254166 0.1631759 0.3420201

sl.lonlat2xyz(lon=seq(-180,180,60), lat=seq(-90,90,30))
## Should return:
## $x
## [1] -6.123234e-17 -2.500000e-01  4.330127e-01  1.000000e+00  4.330127e-01 -2.500000e-01 -6.123234e-17
## 
## $y
## [1] -7.498799e-33 -4.330127e-01 -7.500000e-01  0.000000e+00  7.500000e-01  4.330127e-01  7.498799e-33
## 
## $z
## [1] -1.0000000 -0.8660254 -0.5000000  0.0000000  0.5000000  0.8660254  1.0000000

helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.