hi there,
I'm trying to find a method to test if a point is within a given ellipse, and after an initial look at the information I could find, it's not looking easy - does anyone know of a (fast) way to determine this?
thanks
Printable View
hi there,
I'm trying to find a method to test if a point is within a given ellipse, and after an initial look at the information I could find, it's not looking easy - does anyone know of a (fast) way to determine this?
thanks
Try:
pointWithinEllipse = function ( ex , ey , ea , eb , px , py ) {
var dx = px - ex;
var dy = py - ey;
return (dx*dx)/(ea*ea) + (dy*dy)/(eb*eb) <= 1;
}
ex,ey = position ellipse
ea,eb = radiants of ellipse
px,py = position of point
returns true, if Point is within ellipse or exact on the outline else false
great - thanks for that!