Skip to content

line_intersection.m

Basic Information

  USAGE:   [x, y, f, tA, tB] = line_intersection(xA, yA, xB, yB);

  PURPOSE: Return point of intersection between lines A and B

  INPUTS:  xA, yA = x, y for two points on line A, sizes [1,2]
           xB, yB = x, y for two points on line B, sizes [1,2]
           If called with multiple line-pairs (n), sizes are [n,2]
           For this case any input can still be size [1,2]

  OUTPUTS: x, y = point where lines A and B intersect
           f = flag regarding segment between specified points
             0 = A & B are parallel and never intersect
             1 = A & B are the same line but the segments have no overlap
             2 = A & B intersect but not between specified points
             3 = Line A intersected between specified points
             4 = Line B intersected between specified points
             5 = Both lines intersect between specified points
             6 = A & B are the same line and segments partly overlap (not yet implemented)
             7 = Points xA, yA are the same as xB, yB (not yet implemented)
           tA, fraction given by: x = xA(:,1) + tA.*(xA(:,2)-xA(:,1))
           tB, fraction given by: x = xB(:,1) + tB.*(xB(:,2)-xB(:,1))

Dependencies