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

1 Ansicht (letzte 30 Tage)
Ilya
Ilya am 10 Feb. 2014
Bearbeitet: Ilya am 11 Feb. 2014
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?

Akzeptierte Antwort

Ilya
Ilya am 11 Feb. 2014
Bearbeitet: Ilya am 11 Feb. 2014
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.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 10 Feb. 2014
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 Kommentare
Ilya
Ilya am 10 Feb. 2014
Bearbeitet: Ilya am 10 Feb. 2014
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 am 10 Feb. 2014
Questions should be left in place; a "It was a problem with my data" answer is fine it that proves to be the case.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Bounding Regions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by