Cartesian to spherical coordinate conversion.

cartesian2spherical(x, y = NULL, z = NULL)

Arguments

x

a vector of x coordinates (or a vector of length 3 holding \(x, y, z\))

y

a vector of y coordinates

z

Value

A vector of three spherical coordinates \(r, theta, phi\) of a point represented as \(x, y, z\) in Cartesian coordinates.

See also

Examples

cartesian2spherical(0, 0, 0)
#> $r #> [1] 0 #> #> $theta #> [1] 0 #> #> $phi #> [1] 0 #>
cartesian2spherical(1, 2, 3)
#> $r #> [1] 3.741657 #> #> $theta #> [1] 0.6405223 #> #> $phi #> [1] 1.107149 #>
cartesian2spherical(c(1, 2, 3))
#> $r #> [1] 3.741657 #> #> $theta #> [1] 0.6405223 #> #> $phi #> [1] 1.107149 #>