For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > distance if 3D point to polygon in a plane









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author distance if 3D point to polygon in a plane
Steve

2008-01-30, 11:15 pm

I am looking to find the distance from a 3D point to a 2D polygon
defined by a list of vertices (3D points). Does anyone know an
efficient way to do this (or if there is code available)? I checked
matlab central, and didn't find anything - but I've missed stuff there
before.

If I do have to code this myself, is it correct to assume that I will
project all points to common plane, then reduce this to a 2D point to
polygone problem, find the point on the polygon that is closest to the
projected point, then find the distance between these points in 3D?

Thanks

-Steve
Walter Roberson

2008-01-30, 11:15 pm

In article <8762bcc1-6e89-40e7-9716-62c971b91910@s19g2000prg.googlegroups.com>,
Steve <srjm72499@gmail.com> wrote:
>I am looking to find the distance from a 3D point to a 2D polygon
>defined by a list of vertices (3D points). Does anyone know an
>efficient way to do this (or if there is code available)? I checked
>matlab central, and didn't find anything - but I've missed stuff there
>before.


I don't know if there is a solution to your question already built;
it sounds like the sort of thing that would have been done before,
by someone.

>If I do have to code this myself, is it correct to assume that I will
>project all points to common plane, then reduce this to a 2D point to
>polygone problem, find the point on the polygon that is closest to the
>projected point, then find the distance between these points in 3D?


That doesn't sound to me like the most efficient procedure. It seems to
me that you should be able to take any three points in the polygon that
are not co-linear; three points defines a plane, and there should be
very straight-forward methods to find the normal between the 3D plane
and the point. The projection of that normal onto the 3D plane would
give the closest point on the plane to the point. That point will
either be inside or outside the polygon; test to determine which; you
are finished if it is inside the polygon. If it turns out to be outside
the polygon, then you have reduced the problem to that of finding the
closest point on the polygon to that normal point: that closest polygon
point will also (it seems to me) be the closest point between the
polygon and the 3D point.

There might well be better algorithms than the above; vector
geometry never was my specialty.
--
"All is vanity." -- Ecclesiastes
John D'Errico

2008-01-30, 11:15 pm

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message
<fnr7q4$jan$1@canopus.cc.umanitoba.ca>...
> In article <8762bcc1-6e89-40e7-9716-

62c971b91910@s19g2000prg.googlegroups.com>,
> Steve <srjm72499@gmail.com> wrote:
>
> I don't know if there is a solution to your question already built;
> it sounds like the sort of thing that would have been done before,
> by someone.


Actually, if the polygon is convex, there is a
simple solution, using LDP (Least Distance
Programming.) I've seen a Matlab code for
LDP floating around the internet somewhere.

This does presume a convex polygon. If its
not convex, then all bets are off.

[color=darkred]

Again, it depends on the convexity of your
polygon.

John
Steve

2008-01-31, 5:27 am

Thank you both for your responses - unfortunately, my polygons are not
usually convex...
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com