Intersection points for lines or polygon edges (2024)

Intersection points for lines or polygon edges

collapse all in page

Syntax

[xi,yi] = polyxpoly(x1,y1,x2,y2)

[xi,yi,ii] = polyxpoly(___)

[xi,yi] = polyxpoly(___,'unique')

Description

example

[xi,yi] = polyxpoly(x1,y1,x2,y2) returns the intersection points of two polylines in a planar, Cartesian system, with vertices defined by x1, y1, x2 and y2. The output arguments, xi and yi, contain the x- and y-coordinates of each point at which a segment of the first polyline intersects a segment of the second. In the case of overlapping, collinear segments, the intersection is actually a line segment rather than a point, and both endpoints are included in xi, yi.

[xi,yi,ii] = polyxpoly(___) returns a two-column array of line segment indices corresponding to the intersection points. The k-th row of ii indicates which polyline segments give rise to the intersection point xi(k), yi(k).

To remember how these indices work, just think of segments and vertices as fence sections and posts. The i-th fence section connects the i-th post to the (i+1)-th post. In general, letting i and j denote the scalar values comprised by the k-th row of ii, the intersection indicated by that row occurs where the i-th segment of the first polyline intersects the j-th segment of the second polyline. But when an intersection falls precisely on a vertex of the first polyline, then i is the index of that vertex. Likewise with the second polyline and the index j. In the case of an intersection at the i-th vertex of the first line, for example, xi(k) equals x1(i) and yi(k) equals y1(i). In the case of intersections between vertices, i and j can be interpreted as follows: the segment connecting x1(i), y1(i) to x1(i+1), y1(i+1) intersects the segment connecting x2(j), y2(j) to x2(j+1), y2(j+1) at the point xi(k), yi(k).

example

[xi,yi] = polyxpoly(___,'unique') filters out duplicate intersections, which may result if the input polylines are self-intersecting.

Examples

collapse all

Find Intersection Points Between Rectangle and Polyline

Define and fill a rectangular area in the plane.

xlimit = [3 13];ylimit = [2 8];xbox = xlimit([1 1 2 2 1]);ybox = ylimit([1 2 2 1 1]);mapshow(xbox,ybox,'DisplayType','polygon','LineStyle','none')

Define and display a two-part polyline.

x = [0 6 4 8 8 10 14 10 14 NaN 4 4 6 9 15];y = [4 6 10 11 7 6 10 10 6 NaN 0 3 4 3 6];mapshow(x,y,'Marker','+')

Intersect the polyline with the rectangle.

[xi,yi] = polyxpoly(x,y,xbox,ybox);mapshow(xi,yi,'DisplayType','point','Marker','o')

Intersection points for lines or polygon edges (1)

Display the intersection points; note that the point (12, 8) appears twice because of a self-intersection near the end of the first part of the polyline.

[xi yi]
ans = 8×2 3.0000 5.0000 5.0000 8.0000 8.0000 8.0000 12.0000 8.0000 12.0000 8.0000 13.0000 7.0000 13.0000 5.0000 4.0000 2.0000

You can suppress this duplicate point by using the 'unique' option.

[xi,yi] = polyxpoly(x,y,xbox,ybox,'unique');[xi yi]
ans = 7×2 3.0000 5.0000 5.0000 8.0000 8.0000 8.0000 12.0000 8.0000 13.0000 7.0000 13.0000 5.0000 4.0000 2.0000

Find Intersection Points Between State Border and Small Circle

Open Live Script

Read state polygons into a geospatial table. Create a subtable that contains the California polygon. Display the polygon on a map.

states = readgeotable("usastatehi.shp");row = states.Name == "California";california = states(row,:);figureusamap("california")geoshow(california,"FaceColor","none")

Define a small circle centered off the coast of California.

lat0 = 37;lon0 = -122;rad = 500;[latc,lonc] = scircle1(lat0,lon0,km2deg(rad));plotm(lat0,lon0,"r*")plotm(latc,lonc,"r")

Extract the latitude and longitude coordinates of the California polygon from the geospatial table.

T = geotable2table(california,["Latitude","Longitude"]);[lat,lon] = polyjoin(T.Latitude',T.Longitude');

Find the intersection points between the state of California and the small circle.

[loni,lati] = polyxpoly(lon,lat,lonc,latc);plotm(lati,loni,"bo")

Intersection points for lines or polygon edges (2)

Input Arguments

collapse all

x1, y1, x2, y2Coordinates of polylines
numeric vector

x- or y-coordinates of points in the first or second polyline, specified as a numeric vector. For a given polyline, the x- and y-coordinate vectors must be the same length.

Output Arguments

collapse all

xi, yi — Coordinates of intersection points
numeric column vector

x- or y-coordinates of intersection points, specified as a numeric column vector.

ii — line segment indices
numeric vector

Line segment indices of intersection points, specified as a numeric vector.

Tips

  • If the spacing between points is large, the intersections calculated by the polyxpoly function and the intersections shown on a map display might be different. This is a result of differences between straight lines in the unprojected and projected coordinates. Similarly, there might be differences between the polyxpoly result and intersections that assume great circles or rhumb lines between points.

Version History

Introduced before R2006a

See Also

crossfix | gcxgc | gcxsc | navfix | rhxrh | scxsc

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Intersection points for lines or polygon edges (3)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Intersection points for lines or polygon edges (2024)

FAQs

What are the points of intersection of the sides of a polygon? ›

The vertices of a polygon in a coordinate plane are the points of intersection of the lines that contain the sides of the polygon. Early in the lesson, you have learned that the vertex of a polygon is where two sides meet or intersect.

What is the intersection of two or more lines or edges? ›

In geometry, a vertex ( pl. : vertices or vertexes) is a point where two or more curves, lines, or edges meet or intersect. As a consequence of this definition, the point where two lines meet to form an angle and the corners of polygons and polyhedra are vertices.

Can lines intersect in a polygon? ›

Line crosses the polygon if and only if it crosses one of its edges (ignoring for a second the cases when it passes through a vertex). So, in your case you just need to test all edges of your polygon against your line and see if there's an intersection.

What are the points at which the lines of the edges intersect called? ›

A vertex is the point where two lines intersect – We'll see them a lot in geometric shapes, such as cubes or pyramids. There can be more than one vertex in a shape – Multiple vertex points are known as vertices.

What is a polygon intersection? ›

The point of intersection of two sides of a polygon is called a vertex. Plural form of vertex is vertices. In the given figure A , B and C are the vertices of the given triangle.

How do you check if a point intersects a polygon? ›

One simple way of finding whether the point is inside or outside a simple polygon is to test how many times a ray, starting from the point and going in any fixed direction, intersects the edges of the polygon. If the point is on the outside of the polygon the ray will intersect its edge an even number of times.

How to find points of intersection of two lines? ›

To find the point of intersection algebraically, solve each equation for y, set the two expressions for y equal to each other, solve for x, and plug the value of x into either of the original equations to find the corresponding y-value. The values of x and y are the x- and y-values of the point of intersection.

What is the point of intersection of a line? ›

The point of intersection is the meeting point of two straight lines. If two crossing straight lines have the same equations, the intersection point can be found by solving both equations at the same time.

What is the intersection of 2 lines called? ›

The Point where two lines intersect (cross each other) is called the point of intersection. In the above figure, The lines AC and BD intersect at the point O. So, Point O is the Point of Intersection.

What are the two sides of a polygon intersect? ›

A polygon is a closed figure made by joining line segments, called sides, so that the line segments intersect exactly two other segments. The point where each pair of segments intersects is called a vertex.

Which polygons have intersecting lines? ›

List of self-intersecting polygons
  • pentagram, with five edges.
  • Hexagram, with six edges.
  • heptagram, with seven edges.
  • octagram, with eight edges.
  • enneagram or nonagram, with nine edges.
  • decagram, with ten edges.
  • hendecagram, with eleven edges.
  • dodecagram, with twelve edges.

How do you know if two polygons are intersecting? ›

To be able to decide whether two convex polygons are intersecting (touching each other) we can use the Separating Axis Theorem. Essentially: If two convex polygons are not intersecting, there exists a line that passes between them. Such a line only exists if one of the sides of one of the polygons forms such a line.

What is a point at which two or more lines or edges intersect? ›

ANSWER: A vertex is a specific point on a shape, like a triangle or a 3D object, where the sides or edges meet. On the other hand, a point of intersection is the exact location where two or more lines, curves, or surfaces cross or intersect each other.

What are the two lines or sides that intersect called? ›

Lines that cross each other are called intersecting lines close intersecting linesLines which meet at a point.. The point at which they cross is known as the point of intersection close point of intersectionThe location where two or more lines meet..

What are the corners or points of a polygon? ›

The points where two edges meet are the polygon's vertices or corners.

What is the point where two sides of a polygon intersect? ›

A polygon is a closed figure made by joining line segments, called sides, so that the line segments intersect exactly two other segments. The point where each pair of segments intersects is called a vertex.

What are the points where the sides of a polygon meet? ›

The points where two sides meet are the vertices (or corners) of a polygon.

What is the point formed by the intersection of sides called? ›

Vertex is a point on a polygon where the sides or edges of the object meet or where two rays or line segments meet.

Can the sides of a polygon intersect? ›

A polygon can be self-intersecting, meaning edges cross other edges. (The points of intersection are not vertices.) Regular polygons which are not self-intersecting are identified by an integer corresponding to the number of sides (or vertices) it contains.

References

Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6328

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.