angles_to_torus: Conversion between the angular and Cartesian coordinates of...

View source: R/angles.R

angles_to_torusR Documentation

Conversion between the angular and Cartesian coordinates of the torus

Description

Transforms the angles (\theta_1,\ldots,\theta_d) in [-\pi,\pi)^d into the Cartesian coordinates

(\cos(x_1), \sin(x_1),\ldots,\cos(x_d), \sin(x_d))

of the torus (\mathcal{S}^1)^d, and vice versa.

Usage

angles_to_torus(theta)

torus_to_angles(x)

Arguments

theta

matrix of size c(n, d) with the angles.

x

matrix of size c(n, 2 * d) with the Cartesian coordinates on (\mathcal{S}^1)^d. Assumed to be of unit norm by pairs of coordinates in the rows.

Value

  • angles_to_torus: the matrix x.

  • torus_to_angles: the matrix theta.

Examples

# Check changes of coordinates
torus_to_angles(angles_to_torus(c(0, pi / 3, pi / 2)))
torus_to_angles(angles_to_torus(rbind(c(0, pi / 3, pi / 2), c(0, 1, -2))))
angles_to_torus(torus_to_angles(c(0, 1, 1, 0)))
angles_to_torus(torus_to_angles(rbind(c(0, 1, 1, 0), c(0, 1, 0, 1))))

polykde documentation built on April 16, 2025, 1:11 a.m.