Area of largest isosceles triangle that can be inscribed in an Ellipse whose vertex coincides with one extremity of the major axis
Given an ellipse with half the major and minor axes length A & B, the task is to find the area of the largest isosceles triangle that can be inscribed in the ellipse whose vertex coincides with one extremity of the major axis.
Examples:
Input: A = 1, B = 2
Output: 2.598
Explanation:
Area of the isosceles triangle = ((3 * √3) * A * B) / 4.
Therefore, area = 2.598.Input: A = 2, B = 3
Output: 7.794
Approach: The idea is based on the following mathematical formula:
Proof:
Considering triangle APB,
Area of APB = AB * PQ = (1 / 2) * A * B * (2 sin∅ – sin2∅)Taking derivative:
d(area(APB))/d∅ = ab ( cos∅ – cos2∅)Equating the derivative to zero:
d(area(APB))/d∅ = 0
cos∅ = – (1 / 2)
∅ = 2PI / 3Therefore, area of APB = (3√3) * A * B / 4
Below is the implementation of the above approach:
C++
|
|
2.59808
Time Complexity: O(1)
Auxiliary Space: O(1)
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.
0 comments:
Post a Comment