Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
distance if 3D point to polygon in a plane

Subject: distance if 3D point to polygon in a plane

From: Steve

Date: 31 Jan, 2008 00:33:47

Message: 1 of 4

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

Subject: distance if 3D point to polygon in a plane

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 31 Jan, 2008 01:21:08

Message: 2 of 4

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

Subject: distance if 3D point to polygon in a plane

From: John D'Errico

Date: 31 Jan, 2008 04:41:03

Message: 3 of 4

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 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.

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.


> >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?

Again, it depends on the convexity of your
polygon.

John

Subject: distance if 3D point to polygon in a plane

From: Steve

Date: 31 Jan, 2008 06:46:39

Message: 4 of 4

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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us