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

24 lines
525 B
R
Raw Normal View History

2014-06-02 23:49:28 +00:00
# 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))
}
2014-06-02 23:49:28 +00:00
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
}