R/cart2sph.R

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 eggs package in your browser

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

eggs documentation built on May 2, 2019, 5:23 p.m.