SegmentIntersection:

--------------------------------------------------------------------------
   Compute whether and where two 2D line segments intersect

   Since version 2014.1
--------------------------------------------------------------------------
   Form:
   [int,xi,yi,s,t] = SegmentIntersection( x1, y1, x2, y2, x3, y3, x4, y4 )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   x1      (1,1)   First x-coordinate of first line segment
   y1      (1,1)   First y-coordinate of first line segment
   x2      (1,1)   Second x-coordinate of first line segment
   y2      (1,1)   Second y-coordinate of first line segment
   x3      (1,1)   First x-coordinate of second line segment
   y3      (1,1)   First y-coordinate of second line segment
   x4      (1,1)   Second x-coordinate of second line segment
   y4      (1,1)   Second y-coordinate of second line segment

   -------   
   Outputs
   -------
   int     (1,1)   Flag to indicate whether the two segments intersect
   xi      (1,1)   x-coordinate of intersection
   yi      (1,1)   y-coordinate of intersection
   s       (1,1)   Percent distance along x to intersection
   t       (1,1)   Percent distance along y to intersection

--------------------------------------------------------------------------

Children:

Common: Graphics/NewFig