- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Finding the vertex, focus and directrix of a parabola in C++
In this tutorial, we are going to learn how to find the vertex, focus, and directrix of a parabola. We are given constants of the parabola equation x, y, and z.
There are straightforward formulas to find the vertex, focus, and directrix. Let's them.
Vertex − (-y/2x, 4xz-y^2/4x)
Focus − (-y/2x, 4xz-y^2+1/4x)
Directrix − z-(y^2+1)4x
Example
Let's see the code.
#include <iostream> using namespace std; void findParabolaProperties(float x, float y, float z) { cout << "Vertex: (" << -y/(2*x) << ", " << (((4*x*z) - (y*y))/4*x) << ")" << endl; cout << "Focus: (" << -y/(2*x) << ", " << (((4*x*z) - (y*y)+1)/4*x) << ")" << endl; cout << "Directrix: " << z-((y*y)+1)*4*x << endl; } int main() { float x = 6, y = 4, z = 7; findParabolaProperties(x, y, z); return 0; }
Output
If you run the above code, then you will get the following result.
Vertex: (-0.333333, 228) Focus: (-0.333333, 229.5) Directrix: -401
Conclusion
If you have any queries in the tutorial, mention them in the comment section
Advertisements