# Calculating a point Lat/Lon from another Lat/Lon point angle

I need to make an algorithm: :

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.

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

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.

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);
``````