基于Android-Java的三边测量方法

基于Android-Java的三边测量方法,java,android,location,trilateration,Java,Android,Location,Trilateration,我有一个小问题。。。有人知道我如何实现这一点吗 我需要一个java方法,如下所示: public /*COORDINATE OBJECT*/ getTrilaterationPointBetween( /*COORDINATE OBJECT*/ coordinate1, double distance1, /*COORDINATE OBJECT*/ coordinate2, double distance2, /*COORDINATE OBJECT*/ coordinate3, double d

我有一个小问题。。。有人知道我如何实现这一点吗

我需要一个java方法,如下所示:

public /*COORDINATE OBJECT*/ getTrilaterationPointBetween(
/*COORDINATE OBJECT*/ coordinate1, double distance1,
/*COORDINATE OBJECT*/ coordinate2, double distance2,
/*COORDINATE OBJECT*/ coordinate3, double distance3){

    //MAGIC

    return /*COORDINATE OBJECT*/;
}
在实践中,该方法将接收3个坐标,其中一个坐标的“myLocation”之间的距离

我需要三边测量的算法

我做了一些搜索和测试,结果快把我逼到太平洋中部了

关于对象,非常简单,有两个变量表示纬度和经度

我尝试过这种方法:

static double[] MyTrilateration(Ponto ponto1, double dist1,
                                    Ponto ponto2, double dist2,
                                    Ponto ponto3, double dist3) {

        double[] tmpWAP1 = new double[3];
        double[] tmpWAP2 = new double[3];
        double[] tmpWAP3 = new double[3];

        double tmpLat2, tmpLong2, tmpLat3, tmpLong3;
        double tmpSlide, deg;
        double MyLat, MyLong;

        double[] MyLocation = new double[2];

        tmpLat2  = ponto2.getX() - ponto1.getX();
        tmpLong2 = ponto2.getY() - ponto1.getY();
        tmpLat3  = ponto3.getX() - ponto1.getX();
        tmpLong3 = ponto3.getY() - ponto1.getY();

        tmpSlide = Math.sqrt(Math.pow(tmpLat2,2)+Math.pow(tmpLong2,2));

        deg = (180/Math.PI)*Math.acos( Math.abs(tmpLat2)/Math.abs(tmpSlide));

        if( (tmpLat2>0 && tmpLong2>0) ) {
            deg = 360 - deg;
        }
        else if( (tmpLat2<0 && tmpLong2>0) ) {
            deg = 180 + deg;
        }
        else if( (tmpLat2<0 && tmpLong2<0)){
            deg = 180 - deg;
        }
        else if( (tmpLat2>0 && tmpLong2<0)) {
            deg = deg;
        }

        tmpWAP1[0] = 0.0;
        tmpWAP1[1] = 0.0;
        tmpWAP1[2] = dist1;
        tmpWAP2 = myRotation(tmpLat2, tmpLong2, dist2, deg);
        tmpWAP3 = myRotation(tmpLat3, tmpLong3, dist3, deg);


        MyLat = (Math.pow(tmpWAP1[2],2)-Math.pow(tmpWAP2[2],2)+Math.pow(tmpWAP2[0],2))/(2*tmpWAP2[0]);

        MyLong = (Math.pow(tmpWAP1[2],2)-Math.pow(tmpWAP3[2],2)-Math.pow(MyLat,2)
                +Math.pow(MyLat-tmpWAP3[0],2)+Math.pow(tmpWAP3[1], 2))/(2*tmpWAP3[1]);

        MyLocation = myRotation(MyLat, MyLong, 0, -deg);

        MyLocation[0] = MyLocation[0] + ponto1.getX();
        MyLocation[1] = MyLocation[1] + ponto1.getY();

        return MyLocation;
    }
public String getCoordinateWith(
            Ponto a, Ponto b, Ponto c,
            Float dA,
            Float dB,
            Float dC) {
        Float W, Z, x, y, y2;
        W = dA*dA - dB*dB - a.getX()*a.getX() - a.getY()*a.getY() + b.getX()*b.getX() + b.getY()*b.getY();
        Z = dB*dB - dC*dC - b.getX()*b.getX() - b.getY()*b.getY() + c.getX()*c.getX() + c.getY()*c.getY();

        x = (W*(c.getY()-b.getY()) - Z*(b.getY()-a.getY())) / (2 * ((b.getX()-a.getX())*(c.getY()-b.getY()) - (c.getX()-b.getX())*(b.getY()-a.getY())));
        y = (W - 2*x*(b.getX()-a.getX())) / (2*(b.getY()-a.getY()));
        //y2 is a second measure of y to mitigate errors
        y2 = (Z - 2*x*(c.getX()-b.getX())) / (2*(c.getY()-b.getY()));
        y = (y + y2) / 2;
        return "Position: " + x + " , " + y;
    }

谢谢大家!

我明白了!这是我的方法,对我有效,不是100%准确!适用于z=0且仅适用于3个不同点(二维坐标)

类“Ponto”是一个具有两个值(X和Y/Lat和Lon)的简单类,“double”

公共静态Ponto GetLocationByTrilateralation(
Ponto Ponto 1,双距离1,
Ponto ponto2,双距离2,
Ponto ponto3,双距离3){
//变量声明
Ponto Returno=新Ponto();
double[]P1=新的double[2];
double[]P2=新的double[2];
double[]P3=新的double[2];
double[]ex=新的double[2];
double[]ey=新的double[2];
double[]p3p1=新的double[2];
双jval=0;
双温=0;
双IVA=0;
双p3p1i=0;
双triptx;
双xval;
双yval;
双t1;
双t2;
双t3;
双t;
双exx;
双d;
双eyy;
//波托斯埃姆维托雷斯酒店
//庞托1号
P1[0]=ponto1.getX();
P1[1]=ponto1.getY();
//庞托2号
P2[0]=ponto2.getX();
P2[1]=ponto2.getY();
//庞托3号
P3[0]=ponto3.getX();
P3[1]=ponto3.getY();
//地铁站改造方案
//1号桥中心距离和当地距离
距离1=(距离1/100000);
//2号桥中心与当地居民的距离
距离2=(距离2/100000);
//PONTO 3 E MINHA LOCALIZACAO中心距离
距离3=(距离3/100000);
对于(int i=0;i
您的实际问题是什么?你看到了哪些具体问题?你问了“有人知道这件事吗?”这句话太含糊了,无法回答。对不起。我需要三边测量的算法,你知道怎么实现吗?不,对不起。但是,如果你还没有看到,有一个现存的问题可能会有所帮助:老兄,你的距离是米还是什么?
public static Ponto getLocationByTrilateration(
                Ponto ponto1, double distance1,
                Ponto ponto2, double distance2,
                Ponto ponto3, double distance3){

        //DECLARACAO DE VARIAVEIS
        Ponto retorno = new Ponto();
        double[] P1   = new double[2];
        double[] P2   = new double[2];
        double[] P3   = new double[2];
        double[] ex   = new double[2];
        double[] ey   = new double[2];
        double[] p3p1 = new double[2];
        double jval  = 0;
        double temp  = 0;
        double ival  = 0;
        double p3p1i = 0;
        double triptx;
        double xval;
        double yval;
        double t1;
        double t2;
        double t3;
        double t;
        double exx;
        double d;
        double eyy;

        //TRANSFORMA OS PONTOS EM VETORES
        //PONTO 1
        P1[0] = ponto1.getX();
        P1[1] = ponto1.getY();
        //PONTO 2
        P2[0] = ponto2.getX();
        P2[1] = ponto2.getY();
        //PONTO 3
        P3[0] = ponto3.getX();
        P3[1] = ponto3.getY();

        //TRANSFORMA O VALOR DE METROS PARA A UNIDADE DO MAPA
        //DISTANCIA ENTRE O PONTO 1 E A MINHA LOCALIZACAO
        distance1 = (distance1 / 100000);
        //DISTANCIA ENTRE O PONTO 2 E A MINHA LOCALIZACAO
        distance2 = (distance2 / 100000);
        //DISTANCIA ENTRE O PONTO 3 E A MINHA LOCALIZACAO
        distance3 = (distance3 / 100000);

        for (int i = 0; i < P1.length; i++) {
            t1   = P2[i];
            t2   = P1[i];
            t    = t1 - t2;
            temp += (t*t);
        }
        d = Math.sqrt(temp);
        for (int i = 0; i < P1.length; i++) {
            t1    = P2[i];
            t2    = P1[i];
            exx   = (t1 - t2)/(Math.sqrt(temp));
            ex[i] = exx;
        }
        for (int i = 0; i < P3.length; i++) {
            t1      = P3[i];
            t2      = P1[i];
            t3      = t1 - t2;
            p3p1[i] = t3;
        }
        for (int i = 0; i < ex.length; i++) {
            t1 = ex[i];
            t2 = p3p1[i];
            ival += (t1*t2);
        }
        for (int  i = 0; i < P3.length; i++) {
            t1 = P3[i];
            t2 = P1[i];
            t3 = ex[i] * ival;
            t  = t1 - t2 -t3;
            p3p1i += (t*t);
        }
        for (int i = 0; i < P3.length; i++) {
            t1 = P3[i];
            t2 = P1[i];
            t3 = ex[i] * ival;
            eyy = (t1 - t2 - t3)/Math.sqrt(p3p1i);
            ey[i] = eyy;
        }
        for (int i = 0; i < ey.length; i++) {
            t1 = ey[i];
            t2 = p3p1[i];
            jval += (t1*t2);
        }
        xval = (Math.pow(distance1, 2) - Math.pow(distance2, 2) + Math.pow(d, 2))/(2*d);
        yval = ((Math.pow(distance1, 2) - Math.pow(distance3, 2) + Math.pow(ival, 2) + Math.pow(jval, 2))/(2*jval)) - ((ival/jval)*xval);

        t1 = ponto1.getX();
        t2 = ex[0] * xval;
        t3 = ey[0] * yval;
        triptx = t1 + t2 + t3;
        retorno.setX(triptx);
        t1 = ponto1.getY();
        t2 = ex[1] * xval;
        t3 = ey[1] * yval;
        triptx = t1 + t2 + t3;
        retorno.setY(triptx);

        return retorno;
    }