问题–当给出抛物线方程的系数时,求出抛物线的顶点,焦点和方向。
形成曲线的平面上的一组点,使得该曲线上的任何点与焦点等距都是抛物线。
抛物线的顶点是坐标,它从该坐标最急剧地转向,而a是用于生成曲线的直线。
抛物线方程的标准形式是 。给定a,b和c的值;我们的任务是找到顶点,焦点和Directrix方程的坐标。
例子 –
Input : 5 3 2
Output : Vertex:(-0.3, 1.55)
Focus: (-0.3, 1.6)
Directrix: y=-198
Consult the formula below for explanation.
这个问题是公式实现的简单示例。下面给出了所需的一组公式,这些公式将有助于我们解决该问题。
对于形式的抛物线顶点:
重点:
Directrix:
C++
#include
using namespace std;
// Function to calculate Vertex, Focus and Directrix
void parabola(float a, float b, float c)
{
cout << "Vertex: (" << (-b / (2 * a)) << ", "
<< (((4 * a * c) - (b * b)) / (4 * a))
<< ")" << endl;
cout << "Focus: (" << (-b / (2 * a)) << ", "
<< (((4 * a * c) - (b * b) + 1) / (4 * a))
<< ")" << endl;
cout << "Directrix: y="
<< c - ((b * b) + 1) * 4 * a << endl;
}
// Driver Function
int main()
{
float a = 5, b = 3, c = 2;
parabola(a, b, c);
return 0;
}
Java
// Java program to find the vertex,
// focus and directrix of a parabola
class GFG {
// Function to calculate Vertex,
// Focus and Directrix
static void parabola(float a,
float b, float c)
{
System.out.println("Vertex: (" +
(-b / (2 * a)) + ", " +
(((4 * a * c) - (b * b)) /
(4 * a)) + ")");
System.out.println("Focus: (" +
(-b / (2 * a)) + ", " +
(((4 * a * c) - (b * b) + 1) /
(4 * a)) + ")");
System.out.println("Directrix:" + " y=" +
(int)(c - ((b * b) + 1) *
4 * a));
}
// Driver Function
public static void main(String[] args)
{
float a = 5, b = 3, c = 2;
// Function calling
parabola(a, b, c);
}
}
// This code is contributed by
// Smitha Dinesh Semwal
Python 3
# Function to calculate Vertex,
# Focus and Directrix
def parabola(a, b, c):
print("Vertex: (" , (-b / (2 * a)),
", ", (((4 * a * c) - (b * b))
/ (4 * a)), ")", sep = "")
print("Focus: (" , (-b / (2 * a)),
", ", (((4 * a * c) - (b * b) + 1)
/ (4 * a)), ")", sep = "")
print("Directrix: y=", c - ((b * b)
+ 1) * 4 * a, sep = "")
# Driver Function
a = 5
b = 3
c = 2
parabola(a, b, c)
# This code is contributed by Smitha.
C#
// C# program to find the vertex,
// focus and directrix of a parabola
using System;
class GFG {
// Function to calculate Vertex,
// Focus and Directrix
static void parabola(float a,
float b, float c)
{
Console.WriteLine("Vertex: (" +
(-b / (2 * a)) + ", " +
(((4 * a * c) - (b * b)) /
(4 * a)) + ")");
Console.WriteLine("Focus: (" +
(-b / (2 * a)) + ", " +
(((4 * a * c) - (b * b) + 1) /
(4 * a)) + ")");
Console.Write("Directrix:" + " y=" +
(int)(c - ((b * b) + 1) * 4 * a));
}
// Driver Function
public static void Main()
{
float a = 5, b = 3, c = 2;
// Function calling
parabola(a, b, c);
}
}
// This code is contributed by nitin mittal
PHP
Javascript
输出 –
Vertex:(-0.3, 1.55)
Focus: (-0.3, 1.6)
Directrix: y=-198