📜  寻找抛物线的顶点、焦点和准线

📅  最后修改于: 2021-10-23 08:12:57             🧑  作者: Mango

问题 –当方程的系数给定时,找到抛物线的顶点、焦点和准线。
平面上的一组点形成一条曲线,使得该曲线上的任何点与焦点等距是一条抛物线。
抛物线的顶点是最急转弯的坐标,而 a 是用于生成曲线的直线。

22

抛物线方程的标准形式是y=ax^2+bx+c  .给定 a、b 和 c 的值;我们的任务是找到顶点坐标、焦点坐标和准线方程。
例子 –

Input : 5 3 2
Output : Vertex:(-0.3, 1.55)
         Focus: (-0.3, 1.6)
         Directrix: y=-198
Consult the formula below for explanation.

这个问题是公式实现的一个简单例子。下面给出了一组所需的公式,它们将帮助我们解决这个问题。

对于形式为抛物线y=ax^2+bx+c顶点: (-b/2a, 4ac-b^2/4a)重点: (-b/2a, 4ac-b^2+1/4a)指导线: y=c-(b^2+1)4a

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