Learn R Programming

sphunif (version 1.4.3)

cir_coord_conv: Transforming between polar and Cartesian coordinates

Description

Transformation between a matrix Theta containing M circular samples of size n on \([0, 2\pi)\) and an array X containing the associated Cartesian coordinates on \(S^1:=\{{\bf x}\in R^2:||{\bf x}||=1\}\).

Usage

Theta_to_X(Theta)

X_to_Theta(X)

Value

  • Theta_to_X: the corresponding X.

  • X_to_Theta: the corresponding Theta.

Arguments

Theta

a matrix of size c(n, M) with M samples of size n of circular data on \([0, 2\pi)\). Must not contain NA's.

X

an array of size c(n, 2, M) containing the Cartesian coordinates of M samples of size n of directions on \(S^{1}\). Must not contain NA's.

Examples

Run this code
# Sample
Theta <- r_unif_cir(n = 10, M = 2)
X <- r_unif_sph(n = 10, p = 2, M = 2)

# Check equality
sum(abs(X - Theta_to_X(X_to_Theta(X))))
sum(abs(Theta - X_to_Theta(Theta_to_X(Theta))))

Run the code above in your browser using DataLab