Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point-Line Distance 3-Dimensional #112

Open
emanuelef opened this issue Mar 5, 2023 · 4 comments
Open

Point-Line Distance 3-Dimensional #112

emanuelef opened this issue Mar 5, 2023 · 4 comments

Comments

@emanuelef
Copy link

Hi,
Not an issue but a question.
I'm trying to understand if with geodesy I can get the minimum distance between one 3D point (lat, lon, alt) and the line segment generated by two other 3D points.
This is better explained here:
Point-Line Distance--3-Dimensional

In my case I'm trying to find the minimum distance in meters from a point on the ground (but considering elevation) and a flying object passing by two points.

Thanks

@SkybuckFlying
Copy link

Yes, I tried the same thing.

So far I found two solutions:

The first solution is for one both paths are "straight" and not great circles:
https://www.fundza.com/vectors/point2line/index.html

The second solution I tried using geodesy, but it has some strange issues,I already reported this as an issue, my delphi code is in there, it might give you some ideas how to do it:

#111

I highly suggest you use the code from solution 1 as a starting point and checking point/code.

And then try and develop a solution 2, which tries and use geodesy to account for the bending of earth...

If you find a solution that works across the globe, let me know, my solution so far has some issues, not sure what is causing them... maybe porting issue to Delphi, or maybe it's a more general math issue...

@SkybuckFlying
Copy link

SkybuckFlying commented Mar 6, 2023

I just found a good solution:

https://www.ffi.no/en/research/n-vector/

Example 10:

When implemented correctly the CrossTrackDistance is all you need.

Make sure to normalize the input point though.

Also normalize the normal after computing it for the great circle.

It was well worth it to convert this code from C++ to Delphi...

The final solution/code is actually quite simple and works pretty fast.

@SkybuckFlying
Copy link

There is a problem with that solution though, it seems to not fully respect the line segment... and goes beyond it somehow... strange...

@emanuelef
Copy link
Author

emanuelef commented Mar 6, 2023

Yes, for what I need the point with minimum distance should be on the line segment.
@SkybuckFlying in the link you provided the example seems to be using only lat,lon and not altitude.
What did you use for the "3D points" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants