??? 03/26/10 15:21 Read: times |
#174525 - Don't look too much at the globe Responding to: ???'s previous message |
When computing a long-distance course, you need to know that the earth is a sphere but with slightly flattened poles.
For path matching, you don't. If you are a km or more away from your path, then you are obviously not on the path. And do not extrapolate the short line segments based in the GPS coordinates until you reach the equator or date line or similar. Earth isn't flat, so two-dimensional methods should not be used for "full-earth" computations. Limit yourself to small local areas - such as a circle with radius 1km around your current position. Within that small circle, you can treat earth as flat. So if the north/south angle is more then x arc minutes or arc seconds off from the closest point on the path, you don't need to do anything else. Same with east/est angle, after having corrected for the current north/south angle. Let's assume that the points on your planned route are never given with more than 1km distance (even the input path is intended to be 10,000 km without any turns, you should model the planned route as multiple straight lines short enough that you can ignore the earth curvature. The planned route is then described with a number of points P0, P1, P2, ..., Pn. Then you can compute how many arc minutes that represents 1000m in north/south direction and east/west direction from that specific point. Then you can compute if your current position is within 1000m of either of P0, P1, P2, ..., Pn. If the answer is no - then you are not close to the path, and is obviously not following the planned route (but you may possibly be on the way towards the route). If the answer is yes - you are within 1000m range (possibly checked as delta-latitude and delta-longitude and ignoring any square root) then it is time to check a bit closer. But to check closer, you can ignore angles. You can define your Pi and Pi+1 as position (0,0) and (x,y) meters. And you can convert the current GPS position into a position (x,y) relative Pi. Now you suddenly have Pi,Pi+1 and your Px all expressed as three flat coordinates in a normal X-Y system. Two minutes with Google will then allow you to find how to compute the closest distance between a point and a line segment. You will be able to compute both the closest distance, and at what percentage of the Pi,Pi+1 line segment you are closest. The above simple steps tells you close or not close to the path. And if close, it will tell you where on the path are the closest distance - and what is that distance. To save computation power, you can settle for knowing the smallest distance squared. Next step is to decide if it is enough to worry about the current position, distance to the path, and the current heading. Or if you want to use the previous n GPS positions too when figuring out your correlation with the intended path. The issue: is it important to know how close you was to the path 5 seconds ago, or is it enough to know how close you are to the path now? And how important is it that the current heading matches the direction of the line segment you was closest to? |
Topic | Author | Date |
GPS question | 01/01/70 00:00 | |
Just walk the GPS positions | 01/01/70 00:00 | |
Is this possible? | 01/01/70 00:00 | |
Change coordinate system, leaving angles | 01/01/70 00:00 | |
No poles | 01/01/70 00:00 | |
Don't look too much at the globe | 01/01/70 00:00 |