R/get.ellipse.R

Defines functions get.ellipse

Documented in get.ellipse

#' Calculate points on an ellipse described by the fit argument as returned by fit.ellipse.
#' 
#' Function to calculate the points of the ellipse.
#' 
#' @param fit A list object output from fil.ellipse() function
#' @param n Number of points to render. Defults to n=360.
#' @author Unknown. Sourced from https://www.r-bloggers.com/fitting-an-ellipse-to-point-data/
#' @export

get.ellipse <- function( fit, n=360 ) 
{
  tt <- seq(0, 2*pi, length=n) 
  sa <- sin(fit$angle) 
  ca <- cos(fit$angle) 
  ct <- cos(tt) 
  st <- sin(tt) 
  
  x <- fit$center[1] + fit$maj * ct * ca - fit$min * st * sa 
  y <- fit$center[2] + fit$maj * ct * sa + fit$min * st * ca 
  
  cbind(x=x, y=y) 
}
msxakk89/dat documentation built on April 3, 2020, 5:39 p.m.