R/veganCovEllipse.R

Defines functions veganCovEllipse

veganCovEllipse <-  function(cov, center = c(0,0), scale = 1, npoints = 100)
{
  ## Actually from the vegan package
  ## Basically taken from the 'car' package: The Cirlce
  theta <- (0:npoints) * 2 * pi/npoints
  Circle <- cbind(cos(theta), sin(theta))
  ## scale, center and cov must be calculated separately
  Q <- chol(cov, pivot = TRUE)
  ## pivot takes care of cases when points are on a line
  o <- attr(Q, "pivot")
  t(center + scale * t(Circle %*% Q[,o]))
}
orb16/baselines documentation built on Nov. 20, 2023, 7:56 a.m.