R/sph2cart.R

sph2cart = function(sph) {
  # Convert spherical (egg) coordinates to Cartesian coordinates
  r = sph[1]
  theta = sph[2]
  phi = sph[3]
  x = r*cos(theta)*sin(phi)
  y = r*sin(theta)*sin(phi)
  z = r*cos(phi)
  return (c(x, y, z))
}

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.