1.0

1.0 | 1 rating Rate this file 28 downloads (last 30 days) File Size: 1.16 KB File ID: #25615

Intersection of two lines in 2D

by Andr?

 

20 Oct 2009 (Updated 20 Oct 2009)

Code covered by the BSD License  

Takes four points, gives intersection of their connecting lines

Download Now | Watch this File

File Information
Description

Extremely basic tool, saves the drudgery of doing it yourself.
Takes a,b,u,v (points in the form [ x y]) and computes where the lines a->b and u->v will intersect.
Returns point.
No error checking.

MATLAB release MATLAB 7.4 (R2007a)
Zip File Content  
Other Files intersection.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
20 Oct 2009 Duane Hanselman

function name duplicates a standard MATLAB function name that finds the intersection of two sets.
poor help, no error checking, etc.

content of the file is:
%computes the intersetion of a_b and u_v
% a b u and v have to be 2d point vectors eg. a = [3 4];
x1=a(1);
x2=b(1);
x3=u(1);
x4=v(1);
y1=a(2);
y2=b(2);
y3=u(2);
y4=v(2);

ua = ((x4-x3)*(y1-y3)-(y4-y3)*(x1-x3))/((y4-y3)*(x2-x1)-(x4-x3)*(y2-y1));
x = x1 + ua*(x2 - x1);
y = y1 + ua (y2 - y1);
p = [x,y];

Please login to add a comment or rating.
Updates
20 Oct 2009

changed name (overloaded methods);

Tag Activity for this File
Tag Applied By Date/Time
2d geometry intersection lines Andr? 20 Oct 2009 10:00:02
 

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