rot.sphere: Rotating the Sphere

View source: R/rot.sphere.R

rotationsR Documentation

Rotating the Sphere

Description

Generate the matrix for a specified rotation of the sphere (rot.matrix) and determine the locations of a set of points under that rotation (rot.sphere). Also, rotate a set of points through a specified angle about a specified axis

Usage

rot.matrix(northpole, rad=1)
rot.sphere(points, northpole, rad = 1, inverse = FALSE)
rot.sphere2(points, v, theta)

Arguments

points

The coordinates of points to be rotated. An object of class sp2 or sp3, or a length 2 numeric or 2 column matrix (points given in spherical coordinates) or a length 3 numeric or 3 column matrix (points given in Cartesian coordinates).

northpole

For rot.matrix, rot.sphere: the coordinates of a reference point, given in spherical coordinates as a length 2 numeric or 2 column, 1 row matrix. See argument inverse for more information.

rad

Optional. For rot.matrix, rot.sphere: the radius of the sphere, by default set to 1. Not required in rot.sphere if points is an object of class sp2 or sp3.

inverse

Logical. For rot.matrix, rot.sphere: takes value FALSE for the rotation that sends the point given in northpole to the north pole (i.e. c(0,0)); or TRUE for the inverse of that rotation.

v

For rot.sphere2: the axis about which to rotate the points. A matrix with 2 or 3 columns

theta

For rot.sphere2: the angle through which the points should be rotated, in a clockwise direction. A numeric of length 1, should be at least 0 but less than 2*pi.

Details

It is sometimes necessary to find the locations of points on a sphere under a specified rotation; for example when one of the given points is rotated to the north pole. The benefit of this is that some spherical geometric and trigonometric functions can be more easily evaluated, which is useful in the context of spatial point process analysis.

The function rot.sphere invokes rot.matrix to define the required rotation matrix; this rotation sends the point specified in northpole to the north pole (if inverse=FALSE) along the shortest great circle arc, or vice versa (if inverse=TRUE). However, this rotation may not be entirely suitable for all uses since the longitude at colatitudes 0, pi are arbitrary, and are usually set to 0 for the purposes of calculations, including in the standard matrix rotations that rot.matrix generates matrices for, and rot.sphere performs. As such, the rotation that is performed by rot.sphere may not be the desired rotation: e.g. for similar reasons to that described in the previous paragraph, we may need to rotate the sphere such that a point x1 be rotated to the north pole, and a second point x2 to a semicircle of longitude phi0, however the rotation that sends x1 to the north pole sends x2 to a different longitude, phi1. This can be easily overcome by first performing the rotation that sends x1 to the north pole, then performing a second roation on the result, where northpole=c(0, phi1-phi0) for phi1 > phi0, or northpole=c(0, 2π - (φ_{1}-φ_{0}) for phi1 < phi0. More information about this rotation can be found in Section 3.2.2 of N. I. Fisher et al. (1993).

Under this second rotation (i.e. where the colatitude of the point given in northpole has colatitude 0), the axis of rotation passes through the north and south poles as well as the origin, thus x1 is invariant under the rotation. Note that a rotation where the colatitude of the point given in northpole is pi does not do the same, it sends the south pole to the north pole along the semicircle of longitude specified in northpole. Thus for rotations under which the north and south poles are invariant, ensure that the colatitude of the point passed to northpole is 0.

If the points are to be rotated in a clockwise direction through a known angle about a known axis, then this can be done using rot.sphere2, which applies Rodrigues' rotation formula (see, e.g. Koks, 2006). This can also be used if we know that the rotation will send a point x to a point y along the shortest great circle path. In this case the axis of rotation, v is the unit length vector in the direction of the cross product of x and y, and theta=pi.

The function rot.sphere2 can be used to rotate any point x to the north pole 0sph; simply let theta to be the colatitude of x and v to be the unit length vector in the direction of the cross product of x and 0sph. To rotate a point to the south pole, set v as for rotation to the north pole, and set theta to be pi + the colatitude of x.

To perform an inverse rotation using rot.sphere2, set v to be as for the original rotation, and set theta to be 2pi - the value of theta used in the original rotation.

For rot.sphere, if points is an object of class sp2 or sp3, then its radius will be used rather than that specified in rad.

Value

The output of rot.matrix is the matrix for the specified rotation of the sphere; it has 3 columns and 3 rows. The output of rot.sphere is a 2 column matrix, giving the locations of the points under the specified rotation, in spherical coordinates. The output of rot.sphere2 is in the same format as that which the argument codepoints is given in.

Author(s)

Tom Lawrence <email: tjlawrence@bigpond.com>

References

Fisher, N. I., Embleton, B. J. J. and Lewis, T. (1987) ‘Statistical Analysis of Spherical Data’, 1st paperback edition. Cambridge University Press.

Koks, D. (2006) ‘A Roundabout Route to Geometric Algebra’, in Explorations in Mathematical Physics, ch 4, pp. 144–157. Springer Science + Business Media LLC.

Examples

rot.matrix(northpole=c(pi/3, pi/3), rad=1)

rot.sphere(points=c(pi/3, pi/3), northpole=c(pi/3,pi/3), rad=1, inverse=FALSE)
rot.sphere(points=c(pi/3, pi/3), northpole=c(pi/3,pi/3), rad=1, inverse=TRUE)

rot.sphere2(points=c(pi/3, pi/3), v=c(0,0), theta=pi)


baddstats/spherstat documentation built on Feb. 6, 2023, 1:45 a.m.