Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

point in ellipse #30

Open
kokobango opened this issue Mar 29, 2022 · 2 comments
Open

point in ellipse #30

kokobango opened this issue Mar 29, 2022 · 2 comments

Comments

@kokobango
Copy link

kokobango commented Mar 29, 2022

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);
}
@jeffThompson
Copy link
Owner

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?

@kokobango
Copy link
Author

kokobango commented Apr 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants