R/cart2sph.R

Defines functions cart2sph

cart2sph = function(cart) {
# Convert Cartesian coordinates to spherical (egg) coordinates
  x = cart[1]
  y = cart[2]
  z = cart[3]
  r = sqrt(x^2 + y^2 + z^2)
  theta = atan2(y,x)
  phi = abs(atan2(z, sqrt(x^2 + y^2)) - (pi/2))
  return (c(r, theta, phi))
}

Try the egg package in your browser

Any scripts or data that you put into this service are public.

egg documentation built on May 2, 2019, 5:55 p.m.