Code covered by the BSD License  

Highlights from
Polygon_Intersection

5.0

5.0 | 4 ratings Rate this file 34 Downloads (last 30 days) File Size: 19.43 KB File ID: #18173
image thumbnail

Polygon_Intersection

by Guillaume JACQUENOT

 

01 Jan 2008 (Updated 19 Jun 2009)

This function computes n-times intersection region of shapes collection

| Watch this File

File Information
Description

This function computes n-times intersection region of shapes collection and allows to identify every intersection region in which shapes intersect.

The function takes one argument as input, a structure S containing geometrical descriptions of shapes, and delivers one output argument, a structure containing the different shape intersections, with the shape indexes involded in the intersection and the associated area. The second argument is optional. Display_result is a binary value which indicates whether the result should be displayed (1) or not (0).

Input: S : Structure containing geometrical description of polygons.
        S(i) contains all information relative to the i-th shape
        S(i).P(j) gives access to the geometrical description of the j-th
        element of the i-th shape.
              XData : S(i).P(j).x : Vector
              YData : S(i).P(j).y : Vector
              Hole : S(i).P(j).hole : Binary value (1= hole, 0= fill).
              This binary variable indicates whether the consider polygon
              S(i).P(j) is a hole or not. Hole are represented with
              dotted lines on figures.

Output: Geo : Structure containing geometrical description of the
              intersection polygons, their area, and shape indexes used
              to compute the intersection.

              Geo(i).index contains the polygon indexes
              Geo(i).P contains the geometry of the polygon
                    P is a structure containing XData &
                    YData of polygons.
                    XData : Geo(i).P(j).x : Vector
                    YData : Geo(i).P(j).y : Vector
                    Hole : Geo(i).P(j).hole : Binary value (1
                    = hole, 0= fill)
              Geo(i).area contains the area of the i-th shape.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Polygon Clipper

MATLAB release MATLAB 7 (R14)
Other requirements The function uses Polygon Clipper, a function posted by Hölz. The MEX DLL of this function for Windows is included (Matlab 7 - Win 32). For other platforms, one needs to compile the source code, which can be found on Matlab Exchange (File Id: 8818)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
06 Feb 2009 Ashok Prajapati  
30 Jul 2009 Richard Branch  
14 Jun 2010 gjie Harith  
05 Apr 2011 m4 Chrennikov

Hi, all!
I've faced with problem when in some cases function do not work properly: it returns struct with zero areas. Any ideas on how can I solve this problem?

All P-s in each struct are empty [] except of the last P, which is 1x0 struct, may be this information is important.

Please login to add a comment or rating.
Updates
19 Jun 2009

One bug corrected: degenerated polygons that created crashes are automatically deleted

Tag Activity for this File
Tag Applied By Date/Time
specialized Guillaume JACQUENOT 22 Oct 2008 09:41:19
plotting Guillaume JACQUENOT 22 Oct 2008 09:41:19
intersection Guillaume JACQUENOT 22 Oct 2008 09:41:19
graphics Guillaume JACQUENOT 22 Oct 2008 09:41:19
polygon Guillaume JACQUENOT 22 Oct 2008 09:41:19
overlap Guillaume JACQUENOT 22 Oct 2008 09:41:19
intersection Wojciech 09 Dec 2011 20:38:11

Contact us at files@mathworks.com