We are given focus(x, y) and directrix(ax + by + c) of a parabola and we have to find the equation of parabola using its focus and directrix.
Input: x1 = 0, y1 = 0, a = 2, b = 1, c = 2
Output: equation of parabola is 16.0 x^2 + 9.0 y^2 + -12.0 x + 16.0 y + 24.0 xy + -4.0 = 0.
Input: x1 = -1, y1 = -2, a = 1, b = -2, c = 3
Output:equation of parabola is 4.0 x^2 + 1.0 y^2 + 4.0 x + 32.0 y + 4.0 xy + 16.0 = 0.
Let P(x, y) be any point on the parabola whose focus S(x1, y1) and the directrix is the straight line ax + by + c =0.
Draw PM perpendicular from P on the directrix. then by definition pf parabola distance SP = PM
SP^2 = PM^2
(x - x1)^2 + (y - y1)^2 = ( ( 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 = ( ( 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 = ( ( 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 = a^2*x^2 + b^2*y^2 + 2*a*x*b*y + c^2 + 2*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 = a^2*x^2 + b^2*y^2 + 2*a*x*b*y + c^2 + 2*c*a*x + 2*c*b*y t*x^2 - a^2*x^2 + t*y^2 - b^2*y^2 - 2*t*x1*x - 2*c*a*x - 2*t*y1*y - 2*c*b*y - 2*a*x*b*y - c^2 + t*x1^2 + t*y1^2 =0.
This can be compared with 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 :
equation of parabola is 16.0 x^2 + 9.0 y^2 + -12.0 x + 16.0 y + 24.0 xy + -4.0 = 0.
- Finding the vertex, focus and directrix of a parabola
- Equation of ellipse from its focus, directrix, and eccentricity
- Check if a point is inside, outside or on the parabola
- Equation of circle from centre and radius
- Given equation of a circle as string, find area
- Euler Method for solving differential equation
- Program to find number of solutions in Quadratic Equation
- Program to find equation of a plane passing through 3 points
- Number of ordered points pair satisfying line equation
- Predictor-Corrector or Modified-Euler method for solving Differential equation
- Equation of circle when three points on the circle are given
- Angle subtended by an arc at the centre of a circle
- C++ Program to Illustrate Trigonometric functions
- Maximum number of line intersections formed through intersection of N planes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.