C/C++ Program for Finding the vertex, focus and directrix of a parabola?



Here we will see how to find the vertex, focus directrix of a parabola using C or C++ program. To get these parameters we need the general equation of a parabola. The general formula is −

? = ??+ ?? + ?

The values of a, b and c are given.

The formula for the vertex −

The formula for the focus −

The formula for the Directrix - y −

Example

 Live Demo

#include <bits/stdc++.h> using namespace std; void getParabolaDetails(float a, float b, float c) {    cout << "The vertex: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b)) / (4 * a)) << ")" << endl;    cout << "The Focus: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b) + 1) / (4 * a)) << ")" << endl;    cout << "y-Directrix:" << c - ((b * b) + 1) * 4 * a << endl; } main() {    float a = 10, b = 3, c = 4;    getParabolaDetails(a, b, c); }

Output

The vertex: (-0.15, 3.775) The Focus: (-0.15, 3.8) y-Directrix:-396
Updated on: 2019-07-30T22:30:26+05:30

184 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements