# Scripting Question How to check the mouse is in radial area instead of a rect

Started by Aryesh June 6th, 2019 7:22 AM
• 1055 views
• 4 replies
Is there any logic or algorithm to solve my problem, I know programming and Ruby but not professional and experienced.
So, if you know please tell me, your answer will be appreciated.
If a circle is all you want, you don't even need to do any fancy math.
```dist_x = Math.abs(target_x - mouse_x)
dist_y = Math.abs(target_y - mouse_y)
radius = Math.sqrt(dist_x ** 2 + dist_y ** 2)

# to check if mouse is in a circle of radius 'r' around the target X and Y coordinates, simply check for
# if radius <= r```
If a circle is all you want, you don't even need to do any fancy math.
```dist_x = Math.abs(target_x - mouse_x)
dist_y = Math.abs(target_y - mouse_y)
radius = Math.sqrt(dist_x ** 2 + dist_y ** 2)

# to check if mouse is in a circle of radius 'r' around the target X and Y coordinates, simply check for
# if radius <= r```
Thanks it works
,but abs is not a method of math module ,i think it is of fixnum or it's super class.
ex= -300.abs=>300 ,while Math.abs(-300) gives me error in ruby or rgss.
So you want to know if a point is within an ellipse? Did you try Googling that? "Point ellipse collision" got me this Stack Exchange answer.
i have googled but don't get to that point also complex maths is not completely understandable to me as i want complete access with math .