Sign in to follow this  
Jacob Roman

[RESOLVED]Mouse within 2D circle

Recommended Posts

Details here. (The solution is the same for circles and spheres.) Short answer:
float x = mouse.x-circle.center.x;
float y = mouse.y-circle.center.y;
return (x*x+y*y) <= circle.radius*circle.radius;

Share this post


Link to post
Share on other sites
XC ;circle's X center
YC ;circle's Y center
RC ; circle radius
XM ;mouse X coord
YM ;mouse Y coord

POINT_DIST = SQRT ((XC - XM) ^ 2 + (YC - YM) ^ 2)
IF POINT_DIST > RC THEN POINT_NOT_IN_CIRCLE = TRUE


Oops, too late :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this