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

1 次查看(过去 30 天)
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