Exact and efficient computations on circles in C
GAL- Experiments
Pedro M. M. de Castro, Sylvain Pion, Monique Teillaud
European Workshop on Computational Geometry Graz - 2007
The Computational Geometry Algorithms Library Open Source project
www.cgal.org
>400.000 lines ofC++code
>3.000 pages manual
∼12.000 downloads per year
∼850 users on public mailing list
∼50 developers licenses LGPL or QPL start-up GeometryFactory interfaces: Python,Scilab
Robustness and efficiency Quality:
Editorial board (10 members)
Test-suites each night ...
kernels
Kernel=
elementary geometric objects (points, segments,. . . )
elementary operations on them
(intersection tests, intersection computations,. . . ) Up to release 3.1 (Dec’04):
essentiallylinearobjects Release 3.2 (May ’06):
2Dcircularkernel
[P.-T.]
2D circular kernel design
[Emiris-Kakargias-P.-T.-Tsigaridas socg’04]
Guidelines:
code reuse:
ability toreuse the CGALkernelfor points, circles, number types,. . .
flexibility:
possibility touse other implementationsfor points, circles, number types,. . .
possibility touse several algebraic implementations
template < LinearKernel, AlgebraicKernel > class Circular_kernel
2D circular kernel design
[Emiris-Kakargias-P.-T.-Tsigaridas socg’04]
Guidelines:
code reuse:
ability toreuse the CGALkernelfor points, circles, number types,. . .
flexibility:
possibility touse other implementationsfor points, circles, number types,. . .
possibility touse several algebraic implementations
template < LinearKernel, AlgebraicKernel >
class Circular_kernel
2D circular kernel design
[Emiris-Kakargias-P.-T.-Tsigaridas socg’04]
template < LinearKernel, AlgebraicKernel >
class Circular_kernel
Types
Must be defined byLinear_kernel
basic number types, points, lines,. . . Must be defined byAlgebraic_kernel
algebraic numbers, polynomials Defined byCircular_kernel
Circular_arc_2,Circular_arc_point_2
Predicates
e.g. intersection tests, comparisons of intersection points,. . . exactnessiscrucialfor geometric algorithms Constructions
e.g. computation of intersection points
2D circular kernel design
[Emiris-Kakargias-P.-T.-Tsigaridas socg’04]
template < LinearKernel, AlgebraicKernel >
class Circular_kernel
Types
Must be defined byLinear_kernel
basic number types, points, lines,. . . Must be defined byAlgebraic_kernel
algebraic numbers, polynomials Defined byCircular_kernel
Circular_arc_2,Circular_arc_point_2 Predicates
e.g. intersection tests, comparisons of intersection points,. . . exactnessiscrucialfor geometric algorithms Constructions
e.g. computation of intersection points
Representation
CGALCircle_2:
center
squared radius (rational)
Circular_arc_2:
supporting circleCircle_2
2Circular_arc_point_2 (algebraic)
Circular_arc_point_2 root of system
(system = 2 equations of circles) (algebraic)
Representation
CGALCircle_2:
center
squared radius (rational)
Circular_arc_2:
supporting circleCircle_2
2Circular_arc_point_2 (algebraic)
Circular_arc_point_2 root of system
(system = 2 equations of circles) (algebraic)
Experiments
Computation of arrangements with CGAL3.2 package [Wein-Fogel-Zukerman-Halperin]
* onreal industrial dataofVLSImodels
vlsi_7
VLSI N V E F
vlsi_1 11,929 20,649 26,468 6,385
vlsi_2 9,663 8,556 9,439 887
vlsi_3 35,449 101,758 163,316 61,887
vlsi_4 12,937 81,096 143,049 61,986
vlsi_5 4,063 40,636 77,598 36,965
vlsi_6 74,052 547,250 1,016,460 470,480
vlsi_7 89,918 495,209 878,799 383,871
vlsi_8 123,175 370,304 555,412 190,031
vlsi_9 139,908 1,433,248 2,690,530 1,257,684
* andsynthetic models(very dense and sparse)
Experiments - Results
Pentium 4, 2.5 GHz, 1GB, Linux (2.4.20 Kernel) g++4.0.2, -DNDEBUG -O2 times in seconds Input CGAL3.2 SpecificCGAL CGAL3.3
before arrangements after
vlsi_1 28.0 8.55 4.61
vlsi_2 48.0 2.59 1.31
vlsi_3 135 26.7 21.8
vlsi_4 569 26.9 25.4
vlsi_5 125 14.3 14.8
vlsi_6 611 137 134
vlsi_7 690 192 169
vlsi_8 3,650 220 136
vlsi_9 2,320 581 492
Very dense 335 77.9 76.2
Sparse 0.91 0.51 0.21
Caching
bit-field(2 bytes) inCircular_arc_2 Stores information like
monotone arc full circle . . .
caching intersections
ofeach pairof supporting circles
memory overflow on big data sets−→abandoned
First enhancements of algebraic number type
Optimizingparticular cases
cases when algebraic numbers are in fact rational (intersection of tangent circles)
Arithmetic filtering
general idea for comparison
compute approximate values + error boundε ifεsmall enough: conclude
otherwise compute exact values
Reference counting
High cost of copying coefficients of polynomials
(multiprecision numbers) Storehandlesto objects instead of objects
Copying = copying the reference
Intermediate results
(some of the enhancements were already in the CGALspecific implementation for arrangements)
Input before now SpecificCGAL
arrangements
vlsi_1 28.0 8.42 8.55
vlsi_2 48.0 3.01 2.59
vlsi_3 135 25.8 26.7
vlsi_4 569 33.4 26.9
vlsi_5 125 15.2 14.3
vlsi_6 611 135 137
vlsi_7 690 185 192
vlsi_8 3,650 445 220
vlsi_9 2,320 525 581
Very dense 335 84.5 77.9
Sparse 0.91 0.40 0.51
Further improvements
Representation ofalgebraic numbers
Initialrepresentation ofalgebraic numbers:
root ofax2+bx +c 3rationalcoefficientsa,b,c
(multi-precision-GMP or CGAL::MP_Float) one boolean
Computation of approximation and error for filtering:
(−b±√
b2−4ac)/2a . . .
Newrepresentation ofalgebraic numbers:
α+β√ γ 3 numbersα, β, γ
allows less efficient comparisons, but
reduces the lengthsof multi-precision numbers (and allows additions in easy cases)
Further improvements
Representation ofalgebraic numbers
Initialrepresentation ofalgebraic numbers:
root ofax2+bx +c 3rationalcoefficientsa,b,c
(multi-precision-GMP or CGAL::MP_Float) one boolean
Computation of approximation and error for filtering:
(−b±√
b2−4ac)/2a . . .
Newrepresentation ofalgebraic numbers:
α+β√ γ 3 numbersα, β, γ
allows less efficient comparisons, but
reduces the lengthsof multi-precision numbers (and allows additions in easy cases)
Further improvements
Representation ofalgebraic numbers
Histograms (on vlsi_8)
quantity of numbers vs. lengths (number of digits) Initial
New
Further improvements
Geometric filtering
Forpredicates(e.g. intersection tests) usebounding boxof objects:
Test intersection on the boxes if they don’t intersect: conclude
otherwise test intersection on the exact objects
Results
Input CGAL3.2 SpecificCGAL CGAL3.3 before arrangements after
vlsi_1 28.0 8.55 4.61
vlsi_2 48.0 2.59 1.31
vlsi_3 135 26.7 21.8
vlsi_4 569 26.9 25.4
vlsi_5 125 14.3 14.8
vlsi_6 611 137 134
vlsi_7 690 192 169
vlsi_8 3,650 220 136
vlsi_9 2,320 581 492
Very dense 335 77.9 76.2
Sparse 0.91 0.51 0.21
Conclusion and future work
Combination of
generalityandre-usabilityof the functionality robustnessandefficiency
Integration in CGAL3.3.
Future work
manipulations of spheres, circles, and circular arcs in3D
(submitted to CGAL) [dC.-T.]
filtering ofconstructions?
[Funke-Mehlhorn’00, Fabri-P. lcsd’06]
Work partially supported by the EU STREP Project IST-006413