Home > Backend Development > C++ > C/C++ program to find the vertex, focus and directrix of a parabola

C/C++ program to find the vertex, focus and directrix of a parabola

WBOY
Release: 2023-09-05 17:21:07
forward
1355 people have browsed it

C/C++ program to find the vertex, focus and directrix of a parabola

A set of points on a plain surface that forms a curve such that any point on that curve is equidistant from a point in the center (called focus) is a parabola.

The general equation for the parabola is

y = ax<sup>2</sup> + bx + c
Copy after login

The vertex of a parabola is the coordinate from which it takes the sharpest turn whereas a is the straight-line used to generate the curve.

Focus is the point with is equidistant from all points of the parabola.

Here, we will find the vertex, focus, and directrix of a parabola. There is a mathematical formula that finds all these values. And we will make a program using the mathematical formula for it.

Input:
a = 10,
b = 5,
c = 4
Output:
The vertex: (-0.25, 3.375)
The Focus: (-0.25, 3.4)
y-Directrix:-1036
Copy after login

解释

根据给定的抛物线图形的数值,找到顶点、焦点和y方向的数学公式。

顶点 = {(-b/2a) , (4ac-b2/4a)}

焦点 = {(-b/2a), (4ac-b2 1/4a)}

方向 = c - (b2 1)*4a

示例

#include <iostream>
using namespace std;
int main() {
   float a = 10, b = 5, c = 4;
   cout << "The vertex: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b)) / (4 * a)) << ")\n";
   cout << "The Focus: (" << (-b / (2 * a)) << ", " << (((4 * a * c) - (b * b) + 1) / (4 * a)) << ")\n";
   cout << "y-Directrix:" << c - ((b * b) + 1) * 4 * a;
}
Copy after login

The above is the detailed content of C/C++ program to find the vertex, focus and directrix of a parabola. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template