Description Usage Arguments Details Value Examples
View source: R/SphericalCubature.R
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.
1 2 | polar2rect(r, phi)
rect2polar(x)
|
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. |
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.
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) |
1 2 3 4 5 | x <- matrix( 1:9, nrow=3 )
x
a <- rect2polar( x )
a
polar2rect( a$r, a$phi )
|
Loading required package: cubature
Loading required package: SimplicialCubature
Loading required package: mvmesh
Loading required package: rcdd
If you want correct answers, use rational arithmetic.
See the Warnings sections added to help pages for
functions that do computational geometry.
Loading required package: rgl
Loading required package: geometry
Loading required package: abind
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
3: .onUnload failed in unloadNamespace() for 'rgl', details:
call: fun(...)
error: object 'rgl_quit' not found
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
$r
[1] 3.741657 8.774964 13.928388
$phi
[,1] [,2] [,3]
[1,] 1.3002466 1.0974780 1.044227
[2,] 0.9827937 0.8760581 0.844154
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.