actulab-2014-solution-coope.../ellipse.R

23 lines
525 B
R

# TODO: Add comment
#
# Author: francois
###############################################################################
ellipse_param <- function(t,X,Y,a,b,phi)
{
cbind(X + a * cos(t)*cos(phi) - b*sin(t)*sin(phi),Y + a *
cos(t)*sin(phi) + b*sin(t)*cos(phi))
}
dans_ellipse_param <- function(coord,param)
{
x <- coord[,1]
y <- coord[,2]
xc <- param[1]
yc <- param[2]
a <- param[3]
b <- param[4]
phi <- param[5]
(((x-xc)*cos(phi)-(y-yc)*sin(phi))^2/a^2 +
((x-xc)*sin(phi)+(y-yc)*cos(phi))^2/b^2) <= 1
}