I have been frustrated with the .NET framework's inadequacy when it comes to 2D graphics for quite a while. Instead of implementing the fundamental computational 2D geometry algorithms in .NET, Microsoft has chosen to simply port select GDI+ functions to the realm of managed code.

As a consequence, a System.Drawing.Region object does not consist of a collection of interrelated polygons, as most people would initially assume, but is instead represented as a bitmap (as far as I can tell). This makes boolean operations very fast, but it also means that the smaller geometries you're processing, the less accurate the result will be.

The neat thing about regions is that they can represent polygons with holes in them, which in turn can have islands in them, which may have holes, and so forth. They can represent very complex figures. If you want to know if the 'occupied area' of such a complex figure completely contains another complex figure, the Region class allows you to compute the boolean intersection of those two figures. By comparing the result with the second of the two operand figures, you can determine if that figure is completely contained by the first.

This is where the fun stops, because if the second figure is very small, the inaccuracies introduced by pixelation may cause the intersection function to return an empty result. Since an empty result won't be the same as the second operand figure, you will have to conclude that it is not contained by the first, even when that is indeed the case.

This problem (and others like it) in effect renders the Region class useless for anything but the most basic pixel-oriented operations. If you try to be creative, that will almost certainly get you into trouble.

Since computational geometry libraries are either insanely expensive or only available under GPL, I have spent the last several months writing my own, and it seems I am not done yet. It's been an educating journey, but also a very frustrating one, since, once again, a seemingly mundane detail has exploded into a task of mind-boggling proportions. If you're a software developer, you probably recognize this phenomenon - unless, of course, you've led a very sheltered life.

Anyway, Bill, if you want to spice up .NET with some genuine computational geometry, let me know.