How to cut a polygonal mesh by a line? (Tips needed)
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi, I have got this kind of problem that maybe solved with matalb but I am unsure how:
I have a mesh in its simplest form, a set of (x, y) node coordinates, and a connectivity cell array, for example:
N = [0 0; 0 2; 2 2; 2 0; 1 1];
E = {[1 2 5]; [2 3 5]; [3 4 5]; [4 1 5]}; % all anti-clockwise oriented
Then I have a line given by two points:
x1 = [0.1 0]
x2 = [1.1, 1.2]
What I need to do is to cut the existing mesh and get a new mesh with the new nodes added and the new element to node connectivity cell array.
My idea is to loop over all elements and find the intersections of the line with the boundary of the elements, then add these new nodes and split each polygon accordingly. If a line tip is inside an element (i.e. only one intersection is found) just cut the element in an arbitrary way.
I am looking for tips on how to approach this kind of problem, for example which Matlab functions are best to cut, find intersections etc.? Thanks a lot for reading through.
댓글 수: 0
채택된 답변
Vimal Rathod
2021년 1월 28일
Hi,
You could use 'polyxpoly' function to find the intersection points of the line on the polygon edges which would probably help to solve your issue.
Refer to the following link for more information on the function polyxpoly
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!