VOOZH about

URL: https://www.geeksforgeeks.org/dsa/distance-between-incenter-and-circumcenter-of-a-triangle-using-inradius-and-circumradius/

⇱ Distance between Incenter and Circumcenter of a triangle using Inradius and Circumradius - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Distance between Incenter and Circumcenter of a triangle using Inradius and Circumradius

Last Updated : 9 Sep, 2022

Given two integers r and R representing the length of Inradius and Circumradius respectively, the task is to calculate the distance d between Incenter and Circumcenter.

👁 Image

Inradius The inradius( r ) of a regular triangle( ABC ) is the radius of the incircle (having center as l), which is the largest circle that will fit inside the triangle. 
Circumradius: The circumradius( R ) of a triangle is the radius of the circumscribed circle (having center as O) of that triangle. 

Examples: 

Input: r = 2, R = 5 
Output: 2.24

Input: r = 5, R = 12 
Output: 4.9

Approach: 
The problem can be solved using Euler's Theorem in geometry, which states that the distance between the incenter and circumcenter of a triangle can be calculated by the equation:


Below is the implementation of the above approach:


Output: 
2.24


Time Complexity: O(logn) since time complexity of sqrt is O(logn)
Auxiliary Space: O(1)
 

Comment
Article Tags: