How to use the inpolygon function ??

Hi Matlab Users,
I have 4 Ponints given
X1=[0,0], X2=[2,0], X3=[2,2] and X4=[0,2]
and one point, lets say P=[1,1], that has to be tested whether it is in the convex hull of X1 to X4. How do i actually do that??
Sry, but i don´t understand the explanation for the inpolygon function when it comes to this simple example above.
I'd appreciate your help, With best regards, john

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 18 日
編集済み: Azzi Abdelmalek 2013 年 5 月 18 日

2 投票

X1=[0,0], X2=[2,0], X3=[2,2],X4=[0,2]
X=[X1(1),X2(1),X3(1),X4(1)]
Y=[X1(2),X2(2),X3(2),X4(2)]
inpolygon(1,1,X,Y) % returns 1 because the point (1,1) is inside the polygon
inpolygon(10,1,X,Y)% %returns 0 because the point (10,1) is outside the polygon

4 件のコメント

John
John 2013 年 5 月 18 日
thank you so much!
KalMandy
KalMandy 2016 年 11 月 9 日
Hi, Can I use inpolygon to find out if a point lies on the polygon (on one of it's edges/boundaries)?
Steven Lord
Steven Lord 2016 年 11 月 9 日
See the second output argument of the inpolygon function.
KalMandy
KalMandy 2016 年 11 月 9 日
Found it, Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeComputational Geometry についてさらに検索

質問済み:

2013 年 5 月 18 日

コメント済み:

2016 年 11 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by