필터 지우기
필터 지우기

Get the inverse of polyshape?

조회 수: 10 (최근 30일)
hedgehog
hedgehog 2021년 11월 1일
답변: Steven Lord 2021년 11월 1일
When you have a polygon like:
pgon = polyshape([200 250 260 200],[230 180 250 230])
plot(pgon)
how can you get back the corners of the polygon, i.e. what is the inverse function of polyshape?

답변 (1개)

Steven Lord
Steven Lord 2021년 11월 1일
Do you want to get the vertices from the polyshape object or from the plotted Polygon object?
pgon = polyshape([0 0 1 1],[1 0 0 1])
pgon =
polyshape with properties: Vertices: [4×2 double] NumRegions: 1 NumHoles: 0
V = pgon.Vertices
V = 4×2
0 1 1 1 1 0 0 0
h = plot(pgon)
h =
Polygon with properties: FaceColor: [0 0.4470 0.7410] FaceAlpha: 0.3500 EdgeColor: [0 0 0] LineWidth: 0.5000 LineStyle: '-' Shape: [1×1 polyshape] Show all properties
V2 = h.Shape.Vertices
V2 = 4×2
0 1 1 1 1 0 0 0
Note that V and V2 may not necessarily be the same as the vectors you passed into polyshape if those original vectors specified polygonal regions with collinear points, intersections, or improper nesting. See the "Area of Bow Tie" example on the documentation page for polyshape.
B = polyshape([0 0; 1 1; 1 0; 0 1; 0 0]);
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
V3 = B.Vertices
V3 = 7×2
0 0 0 1.0000 0.5000 0.5000 NaN NaN 1.0000 1.0000 1.0000 0 0.5000 0.5000

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by