Skip to content

intersect_bdry.m

Basic Information

  SYNTAX:  [xi,yi,found] = intersect_bdry(x,y,xstart,ystart,xend,yend,bounded)

  PURPOSE:  Given a set of connected line segments (such as a closed
    boundary) and the end points of an independent line segment,
    find the intersection of the independent segment
    and the boundary.  The first intersection found will be returned
    so for reliability the segment should intersect the boundary
    in at most one place.

  INPUT:
    x,y           = (x,y) of boundary (vectors)
    xstart,ystart = (x,y) of start of independent segment
    xend,yend     = (x,y) of end of independent segment
    bounded = set to 1 to require the intersection to be between endpoints.
           set to 0 to allow intersection anywhere along the infinite lines
        defined by extending the independent line segment and a segment
        in the boundary. (In this case, the intersection will be found
        for the first segment in the bdry which is not parallel to the
        independent segment.

  OUTPUT:
    xi,yi = (x,y) coordinate of intersection
    found = 0, if no intersection found.
       = index of second point on intersecting bdry segment, otherwise.

Dependencies