R/logSphere.R

Defines functions logSphere

Documented in logSphere

#' Compute a log map for a unit hypersphere.
#' @param base A unit vector of length \eqn{m} holding the base point of the tangent space.
#' @param x A unit vector of length \eqn{m} which the log map is taken.
#' @return A tangent vector of length \eqn{m}.
#' @export
logSphere <- function(base, x) {
  tg <- (x - sum(x * base) * base)
  tgNorm <- l2norm(tg)
  if ( !is.na(tgNorm) & isTRUE(all.equal(tgNorm, 0)) ) {
    rep( 0,length(base) )
  } else {
    tg / l2norm(tg) * SpheGeoDist(base,x)
  }
}

Try the frechet package in your browser

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

frechet documentation built on May 29, 2024, 7:35 a.m.