在本教程中,我们将学习如何找到抛物线的顶点,焦点和方向。给出了抛物线方程x,y和z的常数。
有简单的公式可以找到顶点,焦点和方向。让我们吧。
顶点-(-y / 2x,4xz-y ^ 2 / 4x)
焦点-(-y / 2x,4xz-y ^ 2 + 1 / 4x)
Directrix -z-(y ^ 2 + 1)4x
让我们看一下代码。
#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; }输出结果
如果运行上面的代码,则将得到以下结果。
Vertex: (-0.333333, 228) Focus: (-0.333333, 229.5) Directrix: -401
如果您对本教程有任何疑问,请在评论部分中提及它们