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:
lines crossing through a polygon - inpolygon

Subject: lines crossing through a polygon - inpolygon

From: Daphne

Date: 12 Jan, 2011 08:07:06

Message: 1 of 6


Using inpolygon I can find points that are in the polygon. I would like to be able to identify points outside of the polygon, but whose connecting lines cross the polygon. The points are trajectory locations, so each point only connects to two other points (before-after).

I could probably check the line connecting each pair of points for intersections with the polygon, however that would become a pretty inefficient loop for long trajectories...
Does anyone know of a way to do this efficiently?

Thanks,
Daphne

Subject: lines crossing through a polygon - inpolygon

From: Bruno Luong

Date: 12 Jan, 2011 08:40:19

Message: 2 of 6

"Daphne" <daphnew_too_nospam@yahoo.com> wrote in message <igjnfa$7u$1@fred.mathworks.com>...
>
> Using inpolygon I can find points that are in the polygon. I would like to be able to identify points outside of the polygon, but whose connecting lines cross the polygon. The points are trajectory locations, so each point only connects to two other points (before-after).
>
> I could probably check the line connecting each pair of points for intersections with the polygon, however that would become a pretty inefficient loop for long trajectories...
> Does anyone know of a way to do this efficiently?
>

http://www.mathworks.com/matlabcentral/fileexchange/27673-2d-polygon-edges-intersection

Bruno

Subject: lines crossing through a polygon - inpolygon

From: Daphne

Date: 12 Jan, 2011 16:30:09

Message: 3 of 6


Your code is great for determining if and where the intersections are, however I actually need to know which two points the intersection connects.
That's why I thought I would need a loop to check each line between each pair of points.

Daphne


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <igjpdj$rpp$1@fred.mathworks.com>...
> "Daphne" <daphnew_too_nospam@yahoo.com> wrote in message <igjnfa$7u$1@fred.mathworks.com>...
> >
> > Using inpolygon I can find points that are in the polygon. I would like to be able to identify points outside of the polygon, but whose connecting lines cross the polygon. The points are trajectory locations, so each point only connects to two other points (before-after).
> >
> > I could probably check the line connecting each pair of points for intersections with the polygon, however that would become a pretty inefficient loop for long trajectories...
> > Does anyone know of a way to do this efficiently?
> >
>
> http://www.mathworks.com/matlabcentral/fileexchange/27673-2d-polygon-edges-intersection
>
> Bruno

Subject: lines crossing through a polygon - inpolygon

From: Bruno Luong

Date: 12 Jan, 2011 16:50:27

Message: 4 of 6

"Daphne" <daphnew_too_nospam@yahoo.com> wrote in message <igkkuh$840$1@fred.mathworks.com>...
>
> Your code is great for determining if and where the intersections are, however I actually need to know which two points the intersection connects.
> That's why I thought I would need a loop to check each line between each pair of points.
>
> Daphne

Feel free to adapt the code. The intersect segments are known at some point in the code right before the coordinates of intersection are calculated.

Bruno

Subject: lines crossing through a polygon - inpolygon

From: Doug Schwarz

Date: 12 Jan, 2011 19:17:35

Message: 5 of 6

[top posting repaired]

In article <igkkuh$840$1@fred.mathworks.com>,
 "Daphne" <daphnew_too_nospam@yahoo.com> wrote:

> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> <igjpdj$rpp$1@fred.mathworks.com>...
> > "Daphne" <daphnew_too_nospam@yahoo.com> wrote in message
> > <igjnfa$7u$1@fred.mathworks.com>...
> > >
> > > Using inpolygon I can find points that are in the polygon. I would like
> > > to be able to identify points outside of the polygon, but whose
> > > connecting lines cross the polygon. The points are trajectory locations,
> > > so each point only connects to two other points (before-after).
> > >
> > > I could probably check the line connecting each pair of points for
> > > intersections with the polygon, however that would become a pretty
> > > inefficient loop for long trajectories...
> > > Does anyone know of a way to do this efficiently?
> > >
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/27673-2d-polygon-edges-i
> > ntersection
> >
> > Bruno
>
> Your code is great for determining if and where the intersections are,
> however I actually need to know which two points the intersection connects.
> That's why I thought I would need a loop to check each line between each pair
> of points.
>
> Daphne

This may help:

<http://www.mathworks.com/matlabcentral/fileexchange/11837>

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: lines crossing through a polygon - inpolygon

From: Daphne

Date: 13 Jan, 2011 11:06:04

Message: 6 of 6


Thanks Bruno, that would have worked well.

Doug - your code does exactly what I need and more! Thanks so much!

Daphne

Tags for 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