Determine if a polygon is complex.

5 ビュー (過去 30 日間)
Giuseppe
Giuseppe 2014 年 3 月 26 日
編集済み: Sean de Wolski 2014 年 3 月 26 日
I want to determine if a polygon is complex not using inbuilt functions.
This is my rough idea.
for edge = 1:n
for otheredge = 1:n
if edge crosses otheredge
disp ('complex polygon')
else
disp ('non complex polygon')
end
end
I doubt anyone could help me as I have searched high and low with no luck. I don't know how to come up with a value for the edges to determine if they cross or not. I guess maybe you could make all the edges into linear equations ? Also that loop is just a quick brainstorm. Attached is some examples of where the polygon is complex and not.
Shapes c and d are complex. I have no idea how I would figure out d. Maybe calculate the points which are within other points.
Any slight bit of help or input would be appreciated.
NOTE: I am using shoelace formula to calculate area and if some how someone knows how to determine if polygon is complex or not how could I use this information to calculate maybe the area of d.

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 3 月 26 日
編集済み: Sean de Wolski 2014 年 3 月 26 日
If you have the Mapping Toolbox, you can use polyxpoly to test if to line segments intersect. I'm sure there's a utility to do this on the FEX as well.
Actually, geom2d looks like it has an intersection function for this.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by