A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: point detection against ellipses

  1. #1
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335

    point detection against ellipses

    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

  2. #2
    #
    Join Date
    Apr 2002
    Location
    berlin - germany
    Posts
    107
    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

  3. #3
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335
    great - thanks for that!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center