Java程序求抛物线的顶点、焦点和方向
示例
public class Demo{ public static void find_values(float val_1, float val_2, float val_3){ System.out.println("顶点的值是 (" + (-val_2 / (2 * val_1)) + ", "+ (((4 * val_1 * val_3) - (val_2 * val_2)) / (4 * val_1)) + ")"); System.out.println("焦点的值是 (" + (-val_2 / (2 * val_1)) + ", " + (((4 * val_1 * val_3) - (val_2 * val_2) + 1) / (4 * val_1)) + ")"); System.out.println("Directrix的值为 " + (int)(val_3 - ((val_2 * val_2) + 1) * 4 * val_1)); } public static void main(String[] args){ float val_1 = 6, val_2 = 2, val_3 = 9; find_values(val_1, val_2, val_3); } }
输出结果
顶点的值是 (-0.16666667, 8.833333) 焦点的值是 (-0.16666667, 8.875) Directrix的值为 -111