Intersection of Two Lines (line_intersection)
Updated 23 Dec 2021
Finds the intersection of two lines.
[x_int,y_int] = line_intersection(line1,line2)
[x_int,y_int] = line_intersection(line1,line2) returns the intersection
[x_int,y_int] of two lines. Each line can be defined in four different ways:
line = x0: vertical line form (vertical line defined as )
line = [m,b]: slope-intercept form ()
line = [x0,y0,m]: point-slope form ()
line = [x1,y1,x2,y2]: two point form (line that contains the points and )
- Vertical lines can be defined using the vertical line form or the two point form.
- If the two lines are parallel (but not collinear), the function returns positive or negative infinity for the coordinates of the intersection, and a warning is displayed.
- If the two lines are collinear (but not vertical), the function returns
[NaN,NaN]and displays a warning.
- If the two lines are vertical and collinear, the function returns the x-coordinate of the line for the x-coordinate of the intersection, and
NaNfor the y-coordinate of the intersection.
- See "EXAMPLES.mlx" or the "Examples" tab on the File Exchange page for examples.
- See "Intersection_of_Two_Lines.pdf" (also included with download) for the technical documentation.
Tamas Kis (2022). Intersection of Two Lines (line_intersection) (https://github.com/tamaskis/line_intersection-MATLAB/releases/tag/v5.0.4), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!