Program to find the length of Latus Rectum of a Parabola | C ++ program for the above approach ; Function to calculate distance between two points ; Calculating distance ; Function to calculate length of the latus rectum of a parabola ; Stores the co - ordinates of the vertex of the parabola ; Stores the co - ordinates of the focus of parabola ; Print the distance between focus and vertex ; Driver Code ; Given a , b & c ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; float distance ( float x1 , float y1 , float x2 , float y2 ) { return sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ; } float lengthOfLatusRectum ( float a , float b , float c ) { pair < float , float > vertex = { ( - b / ( 2 * a ) ) , ( ( ( 4 * a * c ) - ( b * b ) ) / ( 4 * a ) ) } ; pair < float , float > focus = { ( - b / ( 2 * a ) ) , ( ( ( 4 * a * c ) - ( b * b ) + 1 ) / ( 4 * a ) ) } ; cout << 4 * distance ( focus . first , focus . second , vertex . first , vertex . second ) ; } int main ( ) { float a = 3 , b = 5 , c = 1 ; lengthOfLatusRectum ( a , b , c ) ; return 0 ; }