Spatially Equal (IV)
Today we continue our "Spatially Equal" research started in February. In the meantime I've updated sources of Boost.Geometry to support for the situations described in the blogs I and II of these series.
Our new question is: is a polygon equal to its reverse? In other words: a triangle going from (0,0) to (0,4) and then via (4,0) back to (0,0) is orientated clockwise. Is this triangle considered as spatially equal to a triangle having the same coordinates but orientated counter clockwise?
However, there is a subtility here. In set theory there is the concept of the Complement. Wiki states that "The complement of set A refers to things not in A". The complement of set A can be written as Ac. The complement of a triangle in Spatial Set theory is containing all space outside that triangle. A triangle can be represented as 3 points, and its complement can be represented as three points in opposite direction! So assume that a clockwise oriented triangle contains all points inside, then a counter clockwise orientated triangle contains all points outside that triangle, so all points in the universe excepted the space in that triangle.
So are two triangles with different orientaties spatially equal? On the contrary, if you follow Spatial Set theory, they should not be equal. Are their borders equal? The answer depends on the definition of border, if a line is equal to a line in opposite direction, then yes, else no.
OGC's Simple Feature specification is built upon Spatial Set theory. However its specification does not state the orientation of polygons, and it also does not state if two polygons only differing in orientation are equal...
SQL Server and PostGIS both answer yes on this question: a polygon is equal to its reverse. Used SQL query (SQL Server 2008):
select geometry::STGeomFromText('POLYGON((0 0,0 4,4 0,0 0))',0)
.STEquals(geometry::STGeomFromText('POLYGON((0 0,4 0,0 4,0 0))',0));