sl.barycenter: Compute Barycenter of Points

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sl.barycenter.R

Description

Compute the barycenter of points on a unit sphere. The locations of the three vertices can be provided in x-y-z or lon-lat coordinates. Can be used directly to compute the barycenter (centroid) of a triangle using its vertices, but NOT FOR POLYGONS WITH MORE THAN 3 VERTICES! To that end, use sl.centroid.

Usage

1
sl.barycenter(x = NA, y = NA, z = NA, lon = NA, lat = NA, weights = NA)

Arguments

x

a vector of arbitrary length with the x-coordinates of the points on the unit sphere. If specified, lon and lat are ignored.

y

a vector of the same length as x with the y-coordinates of the points on the unit sphere. Used only if x is specified.

z

a vector of the same length as x with the z-coordinates of the points on the unit sphere. Used only if x is specified.

lon

a vector of arbitrary length with the longitudes of the points. Used only if x is not specified.

lat

a vector of the same length as lon with the latitudes of the points. Used only if x is not specified.

weights

a vector of the length corresponding to the number of points with optional weights of the points.

Details

The computation is based on the x-y-z locations of the three vertices. The directly resulting barycenter is located within the unit sphere and projected from the origin back onto the unit sphere.

Value

lon

longitude of the barycenter

lat

latitude of the barycenter

Author(s)

Helge Goessling

See Also

sl.centroid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Using x-y-z as input:
sl.barycenter(x=c(1,0,0),y=c(0,1,0),z=c(0,0,1))

## Using lon-lat as input:
sl.barycenter(lon=c(0,90,0),lat=c(0,0,90))

## Both should return:
## $lon
## [1] 45
## 
## $lat
## [1] 35.26439

helgegoessling/spheRlab documentation built on Sept. 29, 2017, 6:36 a.m.