6

I need to make an algorithm:

enter image description here:

I have a point O center of a circle of radius r, on this circle there is two point P1 and P2.

  • I know latitude and longitude of point O in degrees
  • I know the radius r in meters
  • I know the latitude and longitude of P1 in degrees

I want to know the latitude and longitude of point P2 on the same circle, I know the angle a in degrees between the line OP1 and OP2.

How to solve this problem?

The gps points O,P1 and P2 are situated in the south of France.

5
  • 2
    If r is pretty small, just use trigonometry.
    – BradHards
    Commented Feb 16, 2015 at 10:06
  • possible duplicate of Calculating Lat/Lng X miles from point
    – Martin F
    Commented Feb 17, 2015 at 5:29
  • This is not a duplicate, since the Known angle is P1OP2, and not the bearing between P1 & P2 Commented Feb 17, 2015 at 12:33
  • 1
    @DevdattaTengshe but can't you calculate the azimuth of P1 and thus, the azimuth of P2?
    – mkennedy
    Commented Feb 17, 2015 at 17:24
  • @mkennedy: You can, but it still wouldn't make it an duplicate due to this intermediary step. Commented Feb 18, 2015 at 10:35

2 Answers 2

3

Point P1 is irrelevant, if it's a circle r will always be the same, this together with the bearing theta and the origin point O are what matters. To find theta, simply trig your way from your provided angle a.

  1. Supposing your surface is a sphere:

    δ = distance r / Earth radius (both in the same units)
    
    lat_P2 = asin(sin lat_O ⋅ cos δ + cos lat_O ⋅ sin δ ⋅ cos θ )
    lon_P2 = lon_O + atan((sin θ ⋅ sin δ ⋅ cos lat_O) / (cos δ − sin lat_O ⋅ sin lat_P2))
    

    In the above formula, lat, lon and theta are to be provided in radians. Theta is, as in your example, the bearing clockwise from the North. Use absolute values if you coordinates are negative.

    This is an adaptation of the Haversine equation, if you want to look it up. It'll be as precise as the Earth radius you choose.

  2. Supposing your surface is an elipsoid:

    Ok, this is way more complicated, so I'll just link you to Vincenty's formula. You want to use the Direct Formula to find your P2. The same precautions apply here, concerning negative coordinates.

1
  • This should be the accepted answer it works perfectly Commented Mar 25, 2021 at 15:02
1

In GeoTools you can use the GeodeticCalculator for this sort of calculation:

    DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
    GeodeticCalculator calc = new GeodeticCalculator(crs);
    GeometryFactory geomFactory = new GeometryFactory();
    Point point = geomFactory.createPoint(new Coordinate(0.0, 50.0));

    calc.setStartingGeographicPoint(point.getX(), point.getY());
    //azimuth in degrees -180 - 180
    double azimuth = 90.0;
    //distance in metres
    double distance = 5000;
    calc.setDirection(azimuth, distance);
    Point2D p = calc.getDestinationGeographicPoint();

    System.out.println(p);
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.