main.java:3: 错误: 类Point是公共的, 应在名为 Point.java 的文件中声明,这是什么错误

public static class Point {

public double x;
public double y;
//定义一个点方法(函数),其表示为自然语言中的平面坐标点
public Point(double x, double y) {
    //定义点的横轴坐标值
    this.x=x;
    //定义点的纵轴坐标值
    this.y=y;
}
//根据已知点计算两点间的距离
public double getDistance(Point p) {
    //定义一个双精度的参数x放两点横轴坐标差值的绝对值
    double x=Math.abs(this.x-p.x);
    //定义一个双精度的参数y放两点纵轴坐标差值的绝对值
    double y=Math.abs(this.y-p.y);
    //根据正弦定理计算出一个双精度的两点坐标距离的值,并将其作为该方法(计算两点间坐标距离)的返回值
    return Math.sqrt(x*x+y*y);
}
//根据已知点计算方位角
public double getAngle(Point p) {
    //定义一个双精度的参数x放两点横轴坐标差值的绝对值
    double x=Math.abs(this.x-p.x);
    //定义一个双精度的参数y放两点纵轴坐标差值的绝对值
    double y=Math.abs(this.y-p.y);
    //定义一个双精度的参数z放y/x的绝对值
    double z=Math.abs(y/x);
    //计算出两点的坐标方位角,并将其作为该方法(计算已知两点构成的边的坐标方位角)的返回值
    return (1/Math.atan(z))/Math.PI*180;
}

}

public interface Check {
public static final int Rou=206265;
double check(Point P1, Point P2);
}

//前方交会测量计算
public static class Front_Intersection implements Check {
public Point pointA = null;
public Point pointB = null;
public double angleA = 0;
public double angleB = 0;

public Point QFJH() {
    // 定义待定淀P的横轴坐标和纵轴坐标
    double x_P = 0;
    double y_P = 0;
    int sign = 1;

    /*
     * 求出P点的坐标算法,根据余切定理式子的程序化,只需将对应点按逆时针顺序放入即可求出待定点,具体算法如下
     */ 
    double sAcB = Math.sin(angleA) * Math.cos(angleB);
    double cAsB = Math.cos(angleA) * Math.sin(angleB);
    double sAsB = Math.sin(angleA) * Math.sin(angleB);

    x_P = (pointA.x * sAcB + pointB.x * cAsB + sign * (pointA.y - pointB.y) * sAsB) / (sAcB + cAsB);
    y_P = (pointA.y * sAcB + pointB.y * cAsB + sign * (pointB.x - pointA.x) * sAsB) / (sAcB + cAsB);

    return new Point(x_P, y_P);// 返回P点的坐标值
}

/*
 * 前方交会检核,返回值为求得的两点的横向位移之差的绝对值。
 * */
@Override
public double check(Point P1, Point P2) {
    // TODO Auto-generated method stub
    return P1.getDistance(P2);
}

}

//侧方交会测量计算
public static class Side_Intersection implements Check {
public Point pointA = null;
public Point pointB = null;
public Point pointC = null;
public Point pointP = null;
public double angleA = 0;
public double angleP = 0;
public double angleB = 180 - ( angleA + angleP );

public Point CFJH(){
    //定义待定淀P的横轴坐标和纵轴坐标
    double x_P =0;
    double y_P =0;
    int sign = 1;
    //求出P点的坐标算法
    double sAcB = Math.sin(angleA)*Math.cos(angleB);
    double cAsB = Math.cos(angleA)*Math.sin(angleB);
    double sAsB = Math.sin(angleA)*Math.sin(angleB);

    x_P = (pointA.x*sAcB + pointB.x*cAsB + sign*(pointA.y - pointB.y)*sAsB) /(sAcB + cAsB);
    y_P = (pointA.y*sAcB + pointB.y*cAsB + sign*(pointB.x - pointA.x)*sAsB) /(sAcB + cAsB);


    return new Point(x_P, y_P);//返回P点的坐标值

}

/*
 * 侧方交会检测方法,返回的是AP的方位角,由于基本的集合知识可以知道AP方位角正弦值的倒数即为观测∠APC的弧度
 * */
@Override
public double check(Point P1, Point P2) {
    // TODO Auto-generated method stub
    return P1.getAngle(P2);
}

}
//主函数
public static class Main {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    /*
     * 前方交会测量实现以及对测量值的检核
     * */
    Point pC1 = new Point(0, 200);
    Point pB1 = new Point(0, 100);
    Point pA1 = new Point(0,0);
    double angleC1 = 44.992/180*Math.PI;
    double angleB11 = 89.999/180*Math.PI;
    double angleB12 = 90.001/180*Math.PI;
    double angleA1 = 45.0/180*Math.PI;

    //建立前方测量的第一次测量对象test
    Front_Intersection test = new Front_Intersection();
    //依次按逆时针放入对应的点和参数值
    test.pointA = pC1;
    test.pointB = pB1;
    test.angleA = angleC1;
    test.angleB = angleB11;
    Point ret = test.QFJH();

    //建立前方测量的第二次测量对象test1
    Front_Intersection test1 = new Front_Intersection();
    //依次按逆时针放入对应的点和参数值
    test1.pointA = pB1;
    test1.pointB = pA1;
    test1.angleA = angleB12;
    test1.angleB = angleA1;
    Point ret0 = test1.QFJH();

    //第一次测量出来的点P的坐标
    Point pP11 = new Point (ret.x , ret.y);
    //第二次测量出来的点P的坐标
    Point pP12 = new Point (ret0.x , ret0.y);
    /*
     * 
     * 以下为输出语句
     * 
     */
    System.out.println("根据点C、B,以及∠C和∠CBP求得点P的第一次测量值:");
    System.out.println("第一次测量出的点P :"+"(" + ret.x + ", " + ret.y +")");
    System.out.println("根据点B、A,以及∠PBA和∠BAP求得点P的第二次测量值:");
    System.out.println("第二次测量出的点P :"+"(" + ret0.x + ", " + ret0.y +")");

    //实现检测方法
    System.out.println("下面进行测量检测:");
    double m = test.check(ret, ret0);
    if(m <= 0.2) {
        System.out.println("检测合格");
        System.out.println("为了更精确P点,取两次测量的平均值:");
        Point AVGP1 = new Point ((ret.x + ret0.x)/2 , (ret.y + ret0.y)/2);
        System.out.println("点P的综合测量值为 :" + "(" + AVGP1.x + ", " + AVGP1.y +")");
        System.out.println("点P到点A的距离为:" + AVGP1.getDistance(pA1));
        System.out.println("点P到点B的距离为:" + AVGP1.getDistance(pB1));
        System.out.println("点P到点C的距离为:" + AVGP1.getDistance(pC1));
        System.out.println("AP的方位角为:" + AVGP1.getAngle(pA1));
        System.out.println("BP的方位角为:" + AVGP1.getAngle(pB1));
        System.out.println("CP的方位角为:" + AVGP1.getAngle(pC1));
    }
    else
        System.out.println("检测不合格 , 需要重新检测!!!");


    /*
     * 
     *  以下为侧方交会的实现以及对测量值的检核
     *
     */

    //侧方交会的参数值
    Point pC2 = new Point(100, 0);
    Point pB2 = new Point(0, 100);
    Point pA2 = new Point(0, 0);
    double angleP2 = 45.002/180*Math.PI;
    double anglePO = 45.005/180*Math.PI;
    double angleA2 = 44.995/180*Math.PI;
    double angleB2 = (90.0 - angleP2 + angleA2)/180*Math.PI;

    //侧方交会的测量对象Test
    Side_Intersection Test= new Side_Intersection();
    //按逆时针顺序依次放入参数
    Test.pointA = pB2;
    Test.pointB = pA2;
    Test.angleA = angleB2;
    Test.angleP = angleP2;
    Point ret1 = Test.CFJH();

    //求得的P点值
    Point pP2 = new Point (ret1.x , ret1.y);

    //定义一个双精度变量n放置测量出来的P点到A的方位角正切值得倒数,即∠APC的测量值
    double n = 1/Math.atan(Test.check(ret1, Test.pointA));
    //定义一个双精度变量l放置点∠APC和观测值和测量值之差的绝对值
    double l = Math.abs(anglePO - n);

    //进行检核判断
    if(l <= 40){
        System.out.println("检测合格");
        System.out.println("点P的综合测量值为 :" + "(" + ret1.x + ", " + ret1.y +")");
        System.out.println("点P到点A的距离为:" + pP2.getDistance(pA2));
        System.out.println("点P到点B的距离为:" + pP2.getDistance(pB2));
        System.out.println("点P到点C的距离为:" + pP2.getDistance(pC2));
        System.out.println("AP的方位角为:" + pP2.getAngle(pA2));
        System.out.println("BP的方位角为:" + pP2.getAngle(pB2));
        System.out.println("CP的方位角为:" + pP2.getAngle(pC2));
    }
    else
        System.out.println("检测不合格 , 需要重新检测!!!");


}

}

1个回答

你的源代码文件名,修改为Point.java即可。
或者public class Point去掉public

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐