Code covered by the BSD License  

Highlights from
Fast Line Segment Intersection

5.0

5.0 | 6 ratings Rate this file 52 Downloads (last 30 days) File Size: 3.5 KB File ID: #27205
image thumbnail

Fast Line Segment Intersection

by U. Murat Erdem

 

08 Apr 2010 (Updated 10 Apr 2010)

Finds the pairwise intersection points between line segments in 2D Cartesian space.

| Watch this File

File Information
Description

OUT = LINESEGMENTINTERSECT(XY1,XY2) generates intersection analysis between the line segment sets given in XY1 and XY2. Code can handle coincident and parallel lines.

The main emphasis is on speed. The code is fully vectorized and it runs pretty fast (orders of magnitude) compared to some of the previous postings.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Fast and Robust Curve Intersections
This submission has inspired the following:
Segments Intersection Test Functions

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
30 Apr 2010 Fabio Pinna

It worked fine and fast for me! Good work!
Good vectorization.
The complex output prevent further vectorization but it is already fast enough

05 Nov 2010 Alex  
05 Nov 2010 Alex

Quick and effective. However, I believe there is a typo in the documentation:

'intNormalizedDistance2To1' : N1xN2 matrix where the (i,j) entry is the normalized distance from the start point of line segment XY1(j,:) to the intersection point with XY2(i,:).

This description is the same as intNormalizedDistance1To2 except that i and j are swapped in the description, and that doesn't really make any sense. I believe XY1 and XY2 should also be swapped.

07 Apr 2011 Maher HAMDI  
16 Jun 2011 piet fue  
03 Aug 2011 Brandon  
18 Mar 2012 Francesco Montorsi

I've found your function very useful, thanks! However I recently wanted to squeeze out some additional performance and ended up rewriting the thing in MEX C code, which can be compiled and run from MATLAB... I posted my code at http://www.mathworks.it/matlabcentral/fileexchange/35492-segments-intersection-test-functions .

Please login to add a comment or rating.
Updates
10 Apr 2010

Changed the input parameters and the output structure. Now the analysis can be done between two sets of line segments. Analysis also provides more information about the intersections.

Please see the CHANGELOG in the comments.

Tag Activity for this File
Tag Applied By Date/Time
intersection U. Murat Erdem 09 Apr 2010 10:57:47
line U. Murat Erdem 09 Apr 2010 10:57:47
segment U. Murat Erdem 09 Apr 2010 10:57:47
fast U. Murat Erdem 09 Apr 2010 10:57:47
fast Matt C 01 Feb 2012 15:28:09
fast Matt C 01 Feb 2012 15:28:09

Contact us at files@mathworks.com