Calculate ratio of area of a triangle inscribed in an Ellipse and the triangle formed by corresponding points on auxiliary circle
Given two integers A and B representing the lengths of semi-major and semi-minor axes of an ellipse, the task is to calculate the ratio of any triangle inscribed in the ellipse and that of the triangle formed by the corresponding points on its auxiliary circle.
Input: A = 1, B = 2
Explanation: Ratio = B / A = 2 / 1 = 2
Input: A = 2, B = 3
The idea is based on the following mathematical formula:
- Let the 3 points on the ellipse be P(a cosX, b sinX), Q(a cosY, b sinY), R(a cosZ, b sinZ).
- Therefore, the corresponding points on the auxiliary circles are A(a cosX, a sinX), B(a cosY, a sinY), C(a cosZ, a sinZ).
- Now, using the formula to calculate the area of triangle using the given points of the triangle.
Area(PQR) / Area(ABC) = b / a
Follow the steps below to solve the problem:
- Store the ratio of the semi-major axis to semi-minor axis of the ellipse in a variable, say result.
- Print the value of result as the required answer.
Below is the implementation of the above approach:
Time Complexity: O(1)
Auxiliary Space: O(1)