Description Usage Arguments Details Value Author(s) Examples
View source: R/directionCosines.R
Convert back and forth between lon/lat and direction cosines and also project spherical coordinates on a local tangent plane.
1 2 3 | directionCosines(x)
toSphere( Grid)
projectionSphere(x1, x2)
|
x |
A two column matrix of lon/lat coordinates in degrees. |
x1 |
A vector of direction cosines defining the intersection of the tangent plane with the unit sphere |
x2 |
A matrix of direction cosines that will be projected onto the plane defined by x2. |
Grid |
A three column matrix of direction cosines |
The conversion functions are based on straight forward definitions of spherical coordinates. The projection function is done by two rotations, first around the Z axis and then around the Y axis.
directionCosines A three column matrix of direction cosines.
toSphere A two column matrix of longitudes and latitudes.
projectionSphere A two column matrix of Euclidean coordinates on the tangent plane to x1
. The convention is that the origin (0,0) is mapped to x1
and the X- axis are points along the meridian through x1
. The Y axis are points on the great circle passing through x1
and perpendicular to the meridian.
Doug Nychka
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #
# icosahedron:
phi = (1 + sqrt(5))/2
V = matrix(c(0, 1, phi, 0, 1, -phi, 0, -1, phi, 0, -1, -phi,
1, phi, 0, -1, phi, 0, 1, -phi, 0, -1, -phi, 0, phi,
0, 1, -phi, 0, 1, phi, 0, -1, -phi, 0, -1), 12, 3, byrow = TRUE)
# check : library( rgl); plot3d( V, size=10, col="red4" )
# as lon lat:
V2<- toSphere( V)
plot( V2)
# lon lat grid
lGrid<- make.surface.grid( list(x= seq( -10,10,, 10), y= seq( -20,20,,10)) )
dGrid<- directionCosines( lGrid)
pairs( dGrid)
# also try: library( rgl); plot3d( dGrid)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.