Transforming between polar and Cartesian coordinates
Transforming between polar and Cartesian coordinates
Transformation between a matrix Theta containing M circular samples of size n on [0,2π) and an array X containing the associated Cartesian coordinates on S1:=x∈R2:∣∣x∣∣=1.
Theta_to_X(Theta)X_to_Theta(X)
Arguments
Theta: a matrix of size c(n, M) with M samples of size n of circular data on [0,2π). 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 S1. Must not contain NA's.
Returns
Theta_to_X: the corresponding X.
X_to_Theta: the corresponding Theta.
Examples
# SampleTheta <- r_unif_cir(n =10, M =2)X <- r_unif_sph(n =10, p =2, M =2)# Check equalitysum(abs(X - Theta_to_X(X_to_Theta(X))))sum(abs(Theta - X_to_Theta(Theta_to_X(Theta))))