R/get.sph.R

get.sph = function(x, z, egg) {
  # Get the spherical coordinate of a given point
  r = NaN
  theta = NaN
  phi = NaN
  pp = t(egg$R%*%cbind(c(x-egg$blunt.end[1], z-egg$blunt.end[2])) + egg$t)
  z.hat = normalise(pp[2], -egg$length/2, egg$length/2, 0, 1)
  tryCatch({
    d = get.d(z.hat, egg)
    phi = acos(dot(norm(c(d, pp[2])), c(0,1)))
    d.prime = sqrt(d^2 - pp[1]^2)
    theta = acos(dot(norm(c(d.prime, pp[1])), c(0,1)))
    r = sqrt(d^2 + pp[2]^2)
  }, warning = function(w) {
    #
  }, error = function(e) {
    #
  }, finally = {
    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.