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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a circle lies inside another circle or not
- Check whether a given point lies inside a triangle or not
- Check whether a given point lies inside a rectangle or not
- Check whether a point lies inside a sphere or not
- Area of a Circular Sector
- Check if any point overlaps the given Circle and Rectangle
- Check whether given circle resides in boundary maintained by two other circles
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check whether a given point lies on or inside the rectangle | Set 3
- Check whether the point (x, y) lies on a given line
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Equation of circle when three points on the circle are given
- Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Area of the circle that has a square and a circle inscribed in it
- Neighbors of a point on a circle using Bresenham's algorithm
- Find minimum radius such that atleast k point lie inside the circle
- Shortest distance between a point and a circle
- Rotation of a point about another point in C++
- Reflection of a point at 180 degree rotation of another point
Improved By : Smitha Dinesh Semwal