 # Geometry :

Subject: [geometry] numeric bounds?
From: Volker Schöch (vschoech_at_[hidden])
Date: 2012-02-16 10:03:12

Hi again,

Here's a new issue I just came across: I have polygons that have one side extending to "infinity" (examples see below). Taking the symmetric difference of these should result in a (multi-)polygon with coordinates in the "normal" range.

As my point base type is int, I tend to use boost::numeric::bounds<int>::highest() when I need some number that is greater than all coordinates that normally occur in my application domain. I understand that some algorithms may not work reliably with coordinates "on the edge" of their domain. As you can see, I accounted for this by using boost::numeric::bounds<int>::highest()/2. This is what I get:

A = MULTIPOLYGON(((1740 1056,2640 1326,3540 1776,3540 1073741823,1740 1073741823)))
area(A) = -2469600
B = MULTIPOLYGON(((1740 1794,2640 2280,3540 2352,3540 1073741823,1740 1073741823)))
area(B) = -3919500
A^B = MULTIPOLYGON()
area(A^B) = 0

If I use a much smaller number, e.g., boost::numeric::bounds<short>::highest(), the results are as expected:

A = MULTIPOLYGON(((1740 1056,2640 1326,3540 1776,3540 32767,1740 32767)))
area(A) = 56512800
B = MULTIPOLYGON(((1740 1794,2640 2280,3540 2352,3540 32767,1740 32767)))
area(B) = 55062900
A^B = MULTIPOLYGON(((1740 1794,1740 1056,2640 1326,3540 1776,3540 2352,2640 2280,1740 1794)))
area(A^B) = 1449900

I am using boost 1.48.0. My polygon type is oriented counter-clockwise and not closed.

My question is: Which are the numeric limits for valid input to the difference and intersection algorithms?

Thank you,
Volker

```--
Volker Schöch | vschoech_at_[hidden]
Senior Software Engineer
think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany
http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091
Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl
```

Geometry list run by mateusz at loskot.net