Code covered by the BSD License  

Highlights from
Intersection of two lines in 2D

1.0

1.0 | 1 rating Rate this file 12 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)

Takes four points, gives intersection of their connecting lines

| 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)
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
2d geometry intersection lines siavash daryadel 19 Jul 2011 13:18:29

Contact us at files@mathworks.com