5.0

5.0 | 1 rating Rate this file 38 downloads (last 30 days) File Size: 10.78 KB File ID: #22444

Minimum distance between two polygons

by Guillaume JACQUENOT

 

15 Dec 2008 (Updated 16 Dec 2008)

Code covered by BSD License  

This function computes the minimum euclidean distance between two polygons P1 & P2.

Download Now | Watch this File

File Information
Description

This function computes the minimum euclidean distance between two
polygons P1 & P2.

min_d = min_dist_between_two_polygons(P1,P2,Display_solution);

This function takes two arguments, a third one is optional.
  P1 & P2 contain the geometry of polygons.
  P1 & P2 are structures containing two fields: x & y
  For example:
        P1.x = rand(1,5)+2;
        P1.y = rand(1,5);
        P2.x = rand(1,3);
        P2.y = rand(1,3);
  Display_solution is a binary variable that enables or not the
  plot of the solution.

The function starts by checking if polygons are intersecting.
In this case, the minimum distance is 0.
Otherwise, distances between all vertices and edges of the two
polygons are computed. The function returns the minimum distance found.
Further details of the implementation can be found in the code.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Curve Intersect 2

MATLAB release MATLAB 7 (R14)
Zip File Content  
Other Files min_dist_between_two_polygons/,
min_dist_between_two_polygons/curveintersect.m,
min_dist_between_two_polygons/min_dist_between_two_polygons.m,
min_dist_between_two_polygons/min_dist_between_two_polygons.png
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
16 Dec 2008 Diego Orlando Barragan Guerrero  
Please login to add a comment or rating.
Updates
15 Dec 2008

Some boundary cases have been taken into account.

16 Dec 2008

Some boundary cases have been taken into account.

Tag Activity for this File
Tag Applied By Date/Time
polygon Cristina McIntire 15 Dec 2008 15:48:10
distance Cristina McIntire 15 Dec 2008 15:48:10
minimum Cristina McIntire 15 Dec 2008 15:48:10
function Cristina McIntire 15 Dec 2008 15:48:32
euclidean Cristina McIntire 15 Dec 2008 15:48:32
polygon Guillaume JACQUENOT 15 Dec 2008 15:48:35
distance Guillaume JACQUENOT 15 Dec 2008 15:48:35
minimum Guillaume JACQUENOT 15 Dec 2008 15:48:35
euclidean Guillaume JACQUENOT 16 Dec 2008 12:17:19
polygon Y Kim 20 Jan 2009 16:33:31
distance Ursula Andersen 26 Feb 2009 16:34:41
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com