How to check if a point(lonc,latc) lie on a great circle running from (lona,lata) to (lonb,latb) [closed]

StackOverflow https://stackoverflow.com/questions/8204998

  •  05-03-2021
  •  | 
  •  

Frage

I'm trying to produce a boolean method that will return true if a point (lonc,latc) lies on a great circle arc starting at (lona,lata) and ending at (lonb,latb)

the point of the method returning true is so if you are in a location where you should be able to see this great circel the section you can see will be shown.

the jist is that you are at (lond,latd) with a small circle at 10degrees radius and I want to work out if the great circle and small circle will intersect. There will be multiple great circles but only one small circle.

I feel the simplest approach is to check any of the longitude and latitudes on the circumference of the small circle lie on a great circle line

any help will be most appreciated

War es hilfreich?

Lösung

You have three latitude-longitude pairs (θa, φa), (θb, φb) and (θc, φc) and you want to determine whether point (θc, φc) lies on the great circle determined by (θa, φa) and (θb, φb). You can accomplish this for example using the following calculations:

  1. Convert all latitude-longitude pairs to (x, y, z) triples using the following formulae: x = sin(θ)*cos(φ), y = sin(θ)*sin(φ), z = cos(θ). This will give you three triples (xa, ya, za), (xb, yb, zb), (xc, yc, zc).

  2. Determine the formula in cartesian coordinates of the plane going through points (xa, ya, za), (xb, yb, zb) and the origin (0, 0, 0). The formula is x+b*y+c*z=0 and we seek b and c which can be determined from two simultaneous equations obtained by substituting coordinates of points A and B for x, y and z in the plane formula x+b*y+c*z=0.

  3. Calculate the distance between point (xc, yc, zc) and the plane determined in point 2 using the following formula: d=abs(xc+b*yc+c*zc)/sqrt(1+b*b+c*c).

  4. From the distance in cartesian coordinates you can find the angular distance between the point (xc, yc, zc) and the great circle determined by (θa, φa) and (θb, φb) using the following formula: α = asin(d).

  5. Since you should not compare floating point numbers exactly you should have an angular threshold which determines how far a point can be from the great circle for you to still consider the point to lie on the circle. You then compare α determined in point 4 with the threshold to come up with the boolean value you seek.

Andere Tipps

assuming you're working on a sphere wich has points a and b marking a cirlce arc. and the you have point c on this sphree and you want to check if c is on the circlearc between a and b...

for this you can check the following:

  1. generate a plane wich is formed from the vectors center-to-a and center-to-b
  2. check if point c intersects with this plane (assuming the point is actually on the sphere, and not above or below it's surface)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top