We have a circle centered at origin (0, 0). As input we are given with starting angle of the circle sector and the size of the circle sector in percentage.
Input : Radius = 8 StartAngle = 0 Percentage = 12 x = 3 y = 4 Output : Point (3, 4) exists in the circle sector Input : Radius = 12 Startangle = 45 Percentage = 25 x = 3 y = 4 Output : Point (3, 4) does not exist in the circle sector
In this image starting angle is 0 degree, radius r and suppose that percentage of colored area is 12% then we calculate Ending Angle as 360/percentage + starting angle.
To find whether a point (x, y) exists in a circle sector (centered at origin) or not we find polar coordinates of that point and then go through the following steps:
- Convert x, y to polar coordinates using this
Angle = atan(y/x); Radius = sqrt(x * x + y * y);
- Then Angle must be between StartingAngle and EndingAngle, and Radius between 0 and your Radius.
Point(3, 4) exists in the circle sector
Time complexity = O(1)
This article is contributed by Niteesh kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Check whether a given point lies inside a triangle or not
- How to check if two given line segments intersect?
- How to check if a given point lies inside or outside a polygon?
- Triangle with no point inside
- Non-crossing lines to connect points in a circle
- Optimum location of point to minimize total distance
- Circle and Lattice Points
- Queries on count of points lie inside a circle
- Find an Integer point on a line segment with given two ends
- Check if four segments form a rectangle
- Pizza cut problem (Or Circle Division by Lines)
- Check if right triangle possible from given area and hypotenuse
- Program to find area of a circle
- How to check if given four points form a square
- Minimum revolutions to move center of a circle to a target
Improved By : Smitha Dinesh Semwal