lemmingapex / trilateration

Solves a formulation of n-D space trilateration problem using a nonlinear least squares optimizer
MIT License
398 stars 106 forks source link

Incorrect calculation of centroid. #3

Closed abd-salam-shaikh closed 8 years ago

abd-salam-shaikh commented 8 years ago

I tried using this project for a given set of co ordinates and rssi values(which is later transformed into distance in meters)

double[][] positions = new double[][]{ {49.8773045,8.654494}, {49.877183,8.6547037} {{49.8772021,8.6548117}}; double[] rssi = new double[]{-69.0, -61.0,-81.0}; // After transformation the rssi values equate to double[] distance = new double[]{14.0,10.0,15.0}

The calculated centroid co ordinates are 48.263028853759394, 12.457544241370318 which locates to some other country. Could you look into this issue ?

bleckers commented 8 years ago

The trilateration algorithm requires all values to be of the same type of units. For example, they should all be in meters.

You will need to convert your lat/lng from decimal degrees to meters using some form of map projection (e.g. Mercator). You will also need to convert your RSSI into a distance of meters using a path loss algorithm.

Once you have done this, you can feed those values into the algorithm. Once calculated, you must then convert the result from the map projection back into decimal degrees.

abd-salam-shaikh commented 8 years ago

Thanks. That worked out for me.

bleckers commented 8 years ago

Just note that the projection can cause errors at certain locations on the Earth. You might be better off with WGS 84 or Web Mercator for example, depending on your application.

abd-salam-shaikh commented 8 years ago

I used https://github.com/rolfrander/geo for the conversion.