fill/patch for a piecewise-linear closed contour/polygon

조회 수: 1 (최근 30일)
Ilya
Ilya 2014년 2월 10일
편집: Ilya 2014년 2월 11일
Hello,
I've tried to use the function fill(X,Y,C) with the set of data specified in the attached m-file (contour_draft.m). The data (XY coordinates) represents a piecewise-linear closed contour, that can be also considered as a polygon with very many sides (since every point can be considered as a polygon vertex, if the points don't lie on the same line).
The contour has three "sides". The two straight lines are in the bottom left, and one "curve" spans from bottom left to the upper right corner of the figure. The joint points of any side with other sides (shown in green) are present in the XY-coordinates of any two adjacent sides (i.e. any two adjacent sides have their common point in their XY-coordinates lists). Then the XY-coordinates of the sides were concantenated in the correct order (i.e. green vertex to green vertex), but somehow the fill-funtion prefers to fill a triangle instead of the full contour.
Is there a way to enforce fill() (or patch()) to fill the whole contour?

채택된 답변

Ilya
Ilya 2014년 2월 11일
편집: Ilya 2014년 2월 11일
Yes, in fact, if a piecewise-linear contour is defined properly (i.e. the sides' points coordinates vectors are concatenated at the common vertices, and the beginning coordinates in the total coordinates' array are equal to the end coordinates), it can be filled with no problem.
I've generated false data in the beginning.
The correct operation is shown below:
The file with the correct coordinates array is also attached.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2014년 2월 10일
If you can put all the vertices together in a patch() then you can set the FaceColor property of the patch in order to fill it.
  댓글 수: 2
Ilya
Ilya 2014년 2월 10일
편집: Ilya 2014년 2월 10일
sorry, seems to be my bad.. the algorithm that groups the sides of the contour together might work wrong in this case. I'm rechecking it. If everything works well after correcting the algorithm, I'll delete the question (then the problem was in my data and not in fill/patch - functions)
Walter Roberson
Walter Roberson 2014년 2월 10일
Questions should be left in place; a "It was a problem with my data" answer is fine it that proves to be the case.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Bounding Regions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by