ContentsIndexReferenceHome
PreviousUpNext
LineIntersect
MATLAB
[Int Px Py Len Para] = LineIntersect(P1x,P1y,P2x,P2y);
Description

Determines if and where 2D polylines intersect.

Parameters
Parameters 
Description 
P1x [vector] 
x axis locations of first polyline 
P1y [vector] 
y axis locations of first polyline 
P2x [vector] 
x axis locations of second polyline 
P2y [vector] 
y axis locations of second polyline 
Return Values
Return Values 
Description 
Int [P1xP2 logical array] 
Intersections tag per polyline segment 
Px [P1xP2 array] 
X axis intersect points 
Py [P1xP2 array] 
Y axis intersect points 
Len [P1xP2 array] 
Length to intersect 
Para [P1xP2 array] 
Parallel tag per polyline segment 
References

  • D. Kirk, Graphic Gems III, pg.188-192. Ap Professional, 1992.

Examples

>> P1x = [8,3,6,1,6,3,3]; 

>> P1y = [2,2,4,7,7,10,7]; 

>> P2x = [5,0,2,6,3]; 

>> P2y = [2,5,5,6,7]; 

>> IntX = [5,3.947,3.647,3]; % Expected X-axis intersects 

>> IntY = [2,2.632,5.412,7]; % Expected Y-axis intersects 

>> [Int Px Py Len Para] = LineIntersect(P1x,P1y,P2x,P2y)

Group
Made with Doc-O-Matic.
Copyright (c) 2009. All rights reserved.
What do you think about this topic? Send feedback!