VOOZH about

URL: https://www.geeksforgeeks.org/dsa/angle-between-3-given-vertices-in-a-n-sided-regular-polygon/

⇱ Angle between 3 given vertices in a n-sided regular polygon - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Angle between 3 given vertices in a n-sided regular polygon

Last Updated : 13 Mar, 2022

Given a n-sided regular polygon and three vertices a1, a2 and a3, the task is to find the angle suspended at vertex a1 by vertex a2 and vertex a3.

Examples: 

Input: n = 6, a1 = 1, a2 = 2, a3 = 4
Output: 90

Input: n = 5, a1 = 1, a2 = 2, a3 = 5
Output: 36

Approach:  

  1. The angle subtended by an edge on the center of n sided regular polygon is 360/n.
  2. The angle subtended by vertices separated by k edges becomes (360*k)/n.
  3. The chord between the vertices subtends an angle with half the value of the angle subtended at the center at the third vertex which is a point on the circumference on the circumcircle.
  4. Let the angle obtained in this manner be a = (180*x)/n where k is number of edges between i and k.
  5. Similarly for the opposite vertex we get the angle to be b = (180*y)/n where l is number of edges between j and k.
  6. The angle between the three vertices thus equals 180-a-b.

Below is the implementation of the above approach:  


Output: 
36

 

Time Complexity: O(1)

Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: