Is it possible to draw partially filed polygons?

5 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 17 Oct 2016
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 Comment
Mike Wilson
Mike Wilson on 18 Oct 2016
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

Sign in to comment.

More Answers (0)

Categories

Find more on Computational Geometry in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!