Given focus(x, y), directrix(ax + by + c) and eccentricity e of an ellipse, the task is to find the equation of ellipse using its focus, directrix, and eccentricity.
Input: x1 = 1, y1 = 1, a = 1, b = -1, c = 3, e = 0.5 Output: 1.75 x^2 + 1.75 y^2 + -5.50 x + -2.50 y + 0.50 xy + 1.75 = 0 Input: x1 = -1, y1 = 1, a = 1, b = -1, c = 3, e = 0.5 Output: 1.75 x^2 + 1.75 y^2 + 2.50 x + -2.50 y + 0.50 xy + 1.75 = 0
Let P(x, y) be any point on the ellipse whose focus S(x1, y1), directrix is the straight line ax + by + c = 0 and eccentricity is e.
Draw PM perpendicular from P on the directrix. Then by definition of ellipse distance SP = e * PM => SP^2 = (e * PM)^2
(x – x1)^2 + (y – y1)^2 = e * ( ( a*x + b*y + c ) / (sqrt( a*a + b*b )) ) ^ 2
let ( a*a + b*b ) = t
x^2 + x1^2 – 2*x1*x + y^2 + y1^2 – 2*y1*y = e * ( ( a*x + b*y + c ) ^ 2 )/ t
on cross multiplying above we get
t*x^2 + t*x1^2 – 2*t*x1*x + t*y^2 + t*y1^2 – 2*t*y1*y = e * ( ( a*x + b*y + c ) ^ 2 )
t*x^2 + t*x1^2 – 2*t*x1*x + t*y^2 + t*y1^2 – 2*t*y1*y = e*a^2*x^2 + e*b^2*y^2 + 2*e*a*x*b*y + e*c^2 + 2*e*c*(a*x + b*y)
t*x^2 + t*x1^2 – 2*t*x1*x + t*y^2 + t*y1^2 – 2*t*y1*y = e*a^2*x^2 + e*b^2*y^2 + 2*e*a*x*b*y + e*c^2 + 2*e*c*a*x + 2*e*c*b*y
t*x^2 – e*a^2*x^2 + t*y^2 – e*b^2*y^2 – 2*t*x1*x – 2*e*c*a*x – 2*t*y1*y – 2*e*c*b*y – 2*e*a*x*b*y – e*c^2 + t*x1^2 + t*y1^2 =0
This can be compared with a general form that is:
a*x^2 + 2*h*x*y + b*y^2 + 2*g*x + 2*f*y + c = 0
Below is the implementation of the above approach:
Equation of ellipse is 1.75 x^2 + 1.75 y^2 + -5.50 x + -2.50 y + 0.50 xy + 1.75 = 0
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.
- Finding the vertex, focus and directrix of a parabola
- Find N numbers such that a number and its reverse are divisible by sum of its digits
- Count of Array elements greater than all elements on its left and at least K elements on its right
- Count of Array elements greater than all elements on its left and next K elements on its right
- Smallest N digit number with none of its digits as its divisor
- Area of a triangle inscribed in a rectangle which is inscribed in an ellipse
- Program to find the Area of an Ellipse
- Area of Largest rectangle that can be inscribed in an Ellipse
- Largest triangle that can be inscribed in an ellipse
- Area of the Largest square that can be inscribed in an ellipse
- Check if a point is inside, outside or on the ellipse
- Find the area of largest circle inscribed in ellipse
- Biggest Reuleaux Triangle inscribed within a square which is inscribed within an ellipse
- Midpoint ellipse drawing algorithm
- Area of the biggest ellipse inscribed within a rectangle
- Largest ellipse that can be inscribed within a rectangle which in turn is inscribed within a semicircle
- Perimeter of an Ellipse
- Absolute difference between sum and product of roots of a quartic equation
- Print values of 'a' in equation (a+b) <= n and a+b is divisible by x
- Equation of circle from centre and radius
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.