Be the first to rate this file! 1 Download (last 30 days) File Size: 1.81 KB File ID: #25501

Curve intersection

by Johan Rønby

 

06 Oct 2009 (Updated 06 Oct 2009)

Finds intersections of two piecewise linear plane curves.

| Watch this File

File Information
Description

[xs,ys] = cint(x1,y1,x2,y2) finds intersection points of the curves defined by straight lines between the length(x1) points in the plane, (x1,y1), and the length(x2) points in the plane (x2,y2).

The function essentially solves

x1(m) + t*diff(x1)(m) = x2(n) + s*diff(x2)(n);
y1(m) + t*diff(y1)(m) = y2(n) + s*diff(y2)(n);

for each combination of line segments and returns

xs = x1 + t*dx1;
ys = y1 + t*dy1;

for all t for which 0<t<1 and 0<s<1 corresponding to an intersection.

For efficiency the function uses bsxfun to construct the length(x1) x length(x2) matrices involved in the calculation.

Points shared by the two arrays (x1,y1) and (x2,y2) are also returned.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
06 Oct 2009

Bug fixed: Earlier version did not return intersection points where a data point from one of the input curves was placed exactly on the line connecting two data points of the other input curve.

06 Oct 2009

Fixed bug introduced by wrong use of unique in last bug fix :-)

Tag Activity for this File
Tag Applied By Date/Time
data exploration Johan Rønby 06 Oct 2009 11:10:38
mathematics Johan Rønby 06 Oct 2009 11:10:39
interpolation Johan Rønby 06 Oct 2009 11:10:39
matrix Johan Rønby 06 Oct 2009 11:10:39
physics Johan Rønby 06 Oct 2009 11:10:39
data exploration Paolo 07 Oct 2009 06:21:46
interpolation Paolo 07 Oct 2009 06:21:51

Contact us at files@mathworks.com