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:
intersection of line&&line and point&&line

Subject: intersection of line&&line and point&&line

From: zac

Date: 22 Aug, 2010 09:33:07

Message: 1 of 2

Hello,

i would like to find intersection of two lines or point and line.
I am using polyxpoly command.
But unfortunately it works only with two lines.
If i have that example:

point:
a = [3 3];
b = [3 3];
line:
c = [1 3];
d = [10 3];

 [xi yi] = polyxpoly([a(1) b(1)],[a(2) b(2)], [c(1) d(1)],[c(2) d(2)]);

the resulat of that is:
xi=yi=[];

But there is an intersection in [x y] = [3 3].

How fix it?
Thanks for any advice.
ZaC.

Subject: intersection of line&&line and point&&line

From: Roger Stafford

Date: 22 Aug, 2010 19:36:05

Message: 2 of 2

"zac " <sony_1000@o2.pl> wrote in message <i4qqsj$lg3$1@fred.mathworks.com>...
> Hello,
>
> i would like to find intersection of two lines or point and line.
> I am using polyxpoly command.
> But unfortunately it works only with two lines.
> If i have that example:
>
> point:
> a = [3 3];
> b = [3 3];
> line:
> c = [1 3];
> d = [10 3];
>
> [xi yi] = polyxpoly([a(1) b(1)],[a(2) b(2)], [c(1) d(1)],[c(2) d(2)]);
>
> the resulat of that is:
> xi=yi=[];
>
> But there is an intersection in [x y] = [3 3].
>
> How fix it?
> Thanks for any advice.
> ZaC.
- - - - - - - - - -
  It requires a numerical calculation to determine whether two line segments have an intersection. In your case one of the line segments is of zero length and I speculate that any error due to rounding in this calculation is likely to cause polyxpoly to conclude that the segments don't intersect. I notice that in the documentation for polyxpoly they make no claims for intersections involving single points, only for lines.

Roger Stafford

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