0

Given a coordinate point X=(lat, lon) and a the centre of a circle C=(lat_center, lon_center) I want to calculate the diametrically opposite coordinates of the point X(assuming that X is inside the circle whose centre is C).

For example, if C=(45.9, 180), the diametrically opposite of X=(45.9, -179) should be (45.9, 179).

the following function is an approximation but does not solve the issue of the latitude being between (-90, 90) and longitude (-180, 180).

def f(lat, lon, center):
  lat_center = center[0]
  lon_center = center[1]
  dist_lon = np.abs(lon - lon_center) if np.abs(lon - lon_center)<180 else 360 - np.abs(lon - lon_center)
  dist_lat = np.abs(lat - lat_center) if np.abs(lat - lat_center)<180 else 360 - np.abs(lat - lat_center)
  lon_op = lon_center + dist_lon if lon_center + dist_lon != lon else lon_center - dist_lon
  lat_op = lat_center + dist_lat if lat_center + dist_lat != lat else lat_center - dist_lat
  return np.round(lat_op, 2), np.round(lon_op, 2)
Javier
  • 71
  • 6
  • How precise do you want the results, and how far is C from X? On the best way: look for geodetic libraries: you calculate distance and direction on a geodetic between X and C, and then you apply direction and distance from C, so you get Y. On shorter distance you may use other tricks (just sphere or also just Cartesian coordinates) – Giacomo Catenazzi Apr 26 '21 at 07:39
  • What are `lat` and `lon`, angles or coodinates? – Yuri Ginsburg Apr 26 '21 at 08:55
  • lat and lon are coordinates – Javier Apr 26 '21 at 09:12

2 Answers2

0

Add the path from the point to the centre of the circle to the circle coordinates?

C=(0, 0) X=(1, 1)

C - X = (-1, -1) # (final - initial) path from X > C

C + (-1, -1) = (-1,-1)

  • This not normalize latitude between (-90, 90) and longitude between (-180, 180) – Javier Apr 26 '21 at 07:56
  • Could you explain that please? Or does this help https://stackoverflow.com/questions/53902475/how-to-normalise-latitude-into-the-range-of-90-to-90 – 6UvNtndXsv Apr 26 '21 at 08:08
0

Using formulas and scripts from this page, we can:

1 ) Calculate bearing from X to C

θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where   
φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)

2 ) Calculate distance from X to C

a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where   φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);
note that angles need to be in radians to pass to trig functions!

3 ) Find Destination point given distance and bearing from start point using the same bearing and doubled distance

φ2 = asin( sin φ1 ⋅ cos δ + cos φ1 ⋅ sin δ ⋅ cos θ )
λ2 = λ1 + atan2( sin θ ⋅ sin δ ⋅ cos φ1, cos δ − sin φ1 ⋅ sin φ2 )
where   φ is latitude, λ is longitude, θ is the bearing (clockwise from north),
δ is the angular distance d/R; d being the distance travelled, R the earth’s radius

(as variant - get distance and bearing from C to X, then use θ+Pi to find point in opposite direction with the same distance (not doubled))

MBo
  • 77,366
  • 5
  • 53
  • 86