VOOZH about

URL: https://www.geeksforgeeks.org/dsa/check-whether-point-exists-circle-sector-not/

⇱ Check whether a point exists in circle sector or not. - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check whether a point exists in circle sector or not.

Last Updated : 22 Jun, 2022

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. 

Examples: 

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


 

👁 Source:wikibooks.org
Source:wikibooks.org


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:

  1. Convert x, y to polar coordinates using this 
    Angle = atan(y/x); Radius = sqrt(x * x + y * y);
  2. Then Angle must be between StartingAngle and EndingAngle, and Radius between 0 and your Radius.

Output : 

Point(3, 4) exists in the circle sector

Time complexity:  O(1)
Auxiliary Space: O(1)


 

Comment
Article Tags:
Article Tags: