rect2polar {SphericalCubature}R Documentation

n-dimensional polar coordinate transformations

Description

Convert between polar and rectangular coordinates in n-dimensions. The point (x[1],...,x[n]) in rectangular coordinates corresponds to the point (r,phi[1],...,phi[n-1]) in polar coordinates.

Usage

polar2rect(r, phi)
rect2polar(x)

Arguments

r

a vector of radii of length m.

phi

angles, a matrix of size (n-1) x m.

x

(n x m) matrix, with column j being the point in n-dimensional space.

Details

n dimensional polar coordinates are given by the following:
rectangular x=(x[1],...,x[n]) corresponds to polar (r,phi[1],...,phi[n-1]) by
x[1] = r*cos(phi[1])
x[j] = r*prod(sin(phi[1:(j-1)]))*cos(phi[j]), 2 <= j <= n-1
...
x[n] = r*sin(phi[1])*sin(phi[2])*...*sin(phi[n-2])*sin(phi[n-1])

This is the defintion used in Wikipedia under the topic 'n-sphere'. There are variations of this definition in use. Here phi[1],...,phi[n-2] are in [0,pi), and phi[n-1] is in [0,2*pi). For multivariate integration, the determinant of the Jacobian of the above tranformation is J(r,phi) = r^(n-1) * prod( sin(phi[1:(n-2)])^((n-2):1) ); note that phi[n-1] does not appear in the Jacobian.

Value

For polar2rect( ), an (n x m) matrix of rectangular coordinates.

For rect2polar( ), a list with fields:

r

a vector of length m containing the radii

phi

angles, a matrix of size (n x m)

Examples

x <- matrix( 1:9, nrow=3 )
x
a <- rect2polar( x )
a
polar2rect( a$r, a$phi )

[Package SphericalCubature version 1.5 Index]