Is it possible to draw partially filed polygons?

1 回表示 (過去 30 日間)
Mike Wilson
Mike Wilson 2016 年 10 月 17 日
コメント済み: Mike Wilson 2016 年 10 月 18 日
Anybody know of an easy way to draw partially filled polygons?
I'm working on a visual flow model for water district and need to show changing storage status of multiple reservoirs (both surface and groundwater). Each has a maximum capacity that would be represented by the full polygon. As the model goes into action and water gets drawn down, I'd like to represent current storage in each reservoir as a fill percentage of its full shape. Looking for an easy way to do this and not finding anything like it in the docs. Any ideas?
Thanks!
Mike

採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 17 日
No, there is no routine provided for this. You need to calculate the height at which the fill percentage is reached, then create a new polygon and fill that.
Calculating the height at which the fill percentage is reached is not trivial for irregularly shaped polygons, especially if the polygons are not convex. For example,
| |
| |
| _____ |
| | |_____|
|_______|
the area on the right cannot fill until the water has raised to a certain level, but once it has raised to that level the water does not start rising again until the right fills up.
You can easily see that you could create two chambers of the same volume with a small gap connecting them near the top; if the fill is into one side only then "almost half full" for the reservoir as a whole would involve having one side completely filled while the other was empty.
If you were to restrict to convex polygons the calculations are easier but still need to proceed piecewise to each change in angle of the sides.
  1 件のコメント
Mike Wilson
Mike Wilson 2016 年 10 月 18 日
Thanks Walter. Pretty much what I expected. I have a quick prototype that does exactly what you suggest. First draws the empty reservoir with no fill (just outlines); then overlays a second filled polygon to show percent full. My reservoirs will be primitive (convex) shapes, so that method will work fine. Just wondered if someone out there had written a function that wraps it all up into a single call.
Cheers,
Mike

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by