它应该计算 y 轴,然后每次在不同的位置绘制一条小线段,并创建保龄球瓶的轮廓。x 值永远不会改变,所以它不会绘制任何东西。黑色实心圆圈只是为了确保它确实在绘制。
import java.util.Scanner;
public class test{
public static void main(String args[])
{
double a0 = 1.27731344;
double a1 = .85418707;
double a2 = .032282353;
double a3 = .127018447;
double a4 = (-5.1957538)*(Math.pow(10,-2));
double a5 = (6.718114)*(Math.pow(10,-3));
double a6 = (-3.61828)*(Math.pow(10,-4));
double a7 = (7.025)*(Math.pow(10,-6));
for(int i=0;i<=150;i++){
for(double x=0;x<=1;x+=(1/150)){
double x2 = x + (1/150);
double y = Math.sqrt((a0)+(a1*x)+(a2*x)+(a3*x)+(a4*x)+(a5*x)+(a6*x)+(a7*x));
StdDraw.line(x,y,x2,y);
System.out.println(x+" "+y+" "+x2);
}
}StdDraw.filledCircle(.5,.5,.25);
}
}