CollisionDetection
CollisionDetection copied to clipboard
point in ellipse
trafficstars
I see many function for circle collision, but do not see any for ellipse. Here is my version for Point / Ellipse:
function pointEllipse(px, py, cx, cy, r1, r2){
var dx = px-cx;
var dy = py-cy;
return ((dx*dx)/(r1*r1)+(dy*dy)/(r2*r2)<=1);
}
Oh wow, thanks! It was my understanding that ellipse collision is super complicated but this seems relatively straightforward. Could you explain the last bit to me?
Oh, this is not my discover. I looked for such collision and found it in one answer. Tested it and it is working very well. Also I found an article for that subject: http://yehar.com/blog/?p=2926