cutpolygon

버전 1.1.0.0 (5.39 KB) 작성자: Jasper Menger
Cut alias slice alias split a 2D surface polygon by a line, and remove the specified part.
다운로드 수: 1.3K
업데이트 날짜: 2010/1/7

라이선스 보기

CUTPOLYGON - Split a 2D polygon by a line, and remove one of the sides

Use CUTPOLYGON to cut alias intersect alias split alias slice a polygon P
(being a series of connected X,Y coordinates) with a line L (defined by
two points), removing a specified side s. L can serve as a bottom limit
('B'), top limit ('T'), left limit ('L'), or right limit ('R').

Syntax:
Pc = CUTPOLYGON(P, L, s, doSplit, doPlot, doTable)

Demo (cut random regular polygon with random line):
CUTPOLYGON demo

Inputs:
P Polygon coordinates [X, Y]
L Line defined by two coordinates [x1, y1; x2, y2]
s What side to remove, character or integer

Optional switches:
doSplit Add intermediate NaN entries if the polygon is split into non-connected parts (default false)
doPlot Plot original and cut polygon plus line (default false)
doTable Tabulate intersection and validity per polygon segment (default false)

Side options:
1 / B = bottom remove parts Y < intersection
2 / T = top remove parts Y > intersection
3 / L = left remove parts X < intersection
4 / R = right remove parts X > intersection

Finding the intersection:
http://en.wikipedia.org/wiki/Line-line_intersection

Output:
- Pc is the polygon post-cut [X, Y]
- Pc can be shorter than P (points are removed)
- Pc can contain intermediate NaN entries if doSplit is true

Version history (recent to ancient):
Jan 2010, Dominik Brands, fixed pure horizontal/vertical limit bug
Apr 2009, Jasper Menger , creation

인용 양식

Jasper Menger (2024). cutpolygon (https://www.mathworks.com/matlabcentral/fileexchange/24449-cutpolygon), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R13
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Elementary Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

Fixed bug for pure horizontal/vertical limits, as suggested by Dominik Brands.

1.0.0.0