Hi I'm currently trying to calculate a longitude/latitude point from 2 longitude/latitude points (bilateration) with distance & I've currenty done that :
    double EARTH_RADIUS = 6378137.0;
    double longitude1 = 4.062787;
    double latitude1 = 49.243828;
    double x1 = EARTH_RADIUS * (Math.cos(Math.toRadians(latitude1)) * Math.cos(Math.toRadians(longitude1)));
    double y1 = EARTH_RADIUS *(Math.cos(Math.toRadians(latitude1)) * Math.sin(Math.toRadians(longitude1)));
    double longitude2 = 4.062023;
    double latitude2 = 49.243851;
    double x2 = EARTH_RADIUS * (Math.cos(Math.toRadians(latitude2)) * Math.cos(Math.toRadians(longitude2)));
    double y2 = EARTH_RADIUS *(Math.cos(Math.toRadians(latitude2)) * Math.sin(Math.toRadians(longitude2)));
    System.out.println(x1 + " " + y1);
    System.out.println(x2 + " " + y2);
    double[][] positions = new double[][] { { x1, y1 }, { x2, y2 } };
    double[] distances = new double[] { 10.0, 10.0};
    NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(new TrilaterationFunction(positions, distances), new LevenbergMarquardtOptimizer());
    Optimum optimum = solver.solve();
    double[] centroid = optimum.getPoint().toArray();
    System.out.println(Arrays.toString(centroid));
I'm using this library https://github.com/lemmingapex/trilateration to trilaterate my point.
Converting longitude & latitude points to a cartesian plan & using a library to get a point on it, giving me this output :
[INFO] GCLOUD: 4153447.729890433 295011.4801210027
[INFO] GCLOUD: 4153449.72871882 294955.95932889543
[INFO] GCLOUD: [4153448.7293046266, 294983.7197249491]
So now I'm trying to convert this point into latitude & longitude point to put it on Google Map but I have no clue how to do that & if a Java library already exist for bilateration?
EDIT :
So I've done that :
private static final double EARTH_RADIUS = 6371; 
private static final int X = 0;
private static final int Y = 1;
private static final int Z = 2;
public static double[] triangulation(double lat0, double lon0, double r0, double lat1, double lon1, double r1) {
    double[] p1 = latlon2cartesian(lat0, lon0);
    double[] p2 = latlon2cartesian(lat1, lon1);
    double[][] positions = new double[][] { { p1[X], p1[Y], p1[Z] }, { p2[X], p2[Y], p2[Z] } };
    double[] distances = new double[] { r0, r1};
    NonLinearLeastSquaresSolver solver = new NonLinearLeastSquaresSolver(new TrilaterationFunction(positions, distances), new LevenbergMarquardtOptimizer());
    Optimum optimum = solver.solve();
    double[] centroid = optimum.getPoint().toArray();
    System.out.println(Arrays.toString(p1));
    System.out.println(Arrays.toString(p2));
    System.out.println(Arrays.toString(centroid));
    return cartesian2latlon(centroid[X], centroid[Y], centroid[Z]);
}
private static double[] latlon2cartesian(double lat, double lon) {
    lat = Math.toRadians(lat);
    lon = Math.toRadians(lon);
    return new double[] { Math.cos(lon) * Math.cos(lat) * EARTH_RADIUS, Math.sin(lon) * Math.cos(lat) * EARTH_RADIUS, Math.sin(lat) * EARTH_RADIUS };
}
private static double[] cartesian2latlon(double x, double y, double z) {
    return new double[] { Math.toDegrees(Math.asin(z / EARTH_RADIUS)), Math.toDegrees(Math.atan2(y, x)) };
}
But I don't get correct values with :
System.out.println(Arrays.toString(Bilateration.triangulation(49.243828, 4.062787, 5.0, 49.243851, 4.062023, 6.5)));
I get :
[49.2453096100026, 3.9213007384886387]
Near (2km away) but the point should be around 49.24385234064716, 4.062335368930235.