Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Computational Geometry
Efi Fogel
Tel Aviv University
Computational Geometry Algorithm LibraryMay. 11th, 2020
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 2
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 3
Cgal: Mission
“Make the large body of geometric algorithms developed in the field ofcomputational geometry available for industrial applications”
Cgal Project Proposal, 1996
Computational Geometry 4
Cgal Facts
A collection of software packages written in C++
Adheres the generic programming paradigmDevelopment started in 1995An open source librarySeveral active contributor sitesHigh search-engine ranking for www.cgal.org
Used in a diverse range of domainse.g., computer graphics, scientific visualization, computer aided designand modeling, additive manufacturing, geographic information systems,molecular biology, medical imaging, and VLSI
The de-facto standard in applied Computational Geometry
Computational Geometry 5
Cgal in Numbers
600,000 lines of C++ code10,000 downloads per year not including Linux distributions4,500 manual pages (user and reference manual)1,000 subscribers to user mailing list200 commercial users120 packages30 active developers6 months release cycle2 licenses: Open Source and commercial
Computational Geometry 6
Cgal HistoryYear Version Released Other Milestones1996 Cgal founded1998 July 1.11999 Work continued after end of European support2001 Aug 2.3 Editorial Board established2002 May 2.42003 Nov 3.0 Geometry Factory founded...
2008 CMake2009 Jan 3.4, Oct 3.52010 Mar 3.6, Oct 3.7 Google Summer of Code (GSoC) 20102011 Apr 3.8, Aug 3.9 GSoC 20112012 Mar 4.0, Oct 4.1 GSoC 20122013 Mar 4.2, Oct 4.3 GSoC 2013, Doxygen2014 Apr 4.4, Oct 4.5 GSoC 20142015 Apr 4.6, Oct 4.7 GitHub, HTML5, Main repository made public2016 Apr 4.8, Sep 4.9 Only headers, 20th anniversary2017 May 4.10, Sep 4.11 CTest, GSoC 20172018 Apr 4.12 GSoC 20182019 Nov 5.0 C++14, GSoC 20192020 5.1 GSoC 2020
Computational Geometry 7
Cgal Properties
ReliabilityExplicitly handles degeneraciesFollows the Exact Geometric Computation (EGC) paradigm
EfficiencyDepends on leading 3rd party libraries
F e.g., Boost, Gmp, Mpfr, Qt, Eigen, Tbb, and CoreAdheres to the generic-programming paradigm
F Polymorphism is resolved at compile time
The best of both worlds
Computational Geometry 8
Cgal Properties, Cont
FlexibilityAdaptable, e.g., graph algorithms can directly be applied to Cgal datastructuresExtensible, e.g., data structures can be extended
Ease of UseHas didactic and exhaustive ManualsFollows standard concepts (e.g., C++ and Stl)Has a modular structure, e.g., geometry and topology are separatedCharacterizes with a smooth learning-curve
Computational Geometry 9
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 10
2D Algorithms and Data Structures
Triangulations Mesh Generation Polyline Simplification Voronoi Diagrams
Arrangements Boolean Operations Neighborhood Queries Minkowski Sums Straight Skeleton
Computational Geometry 11
3D Algorithms and Data Structures
Triangulations Mesh Generation Polyhedral Surface Deformation Boolean Operations
Mesh Simplification Skeleton Segmentation Classification Hole Filling
Computational Geometry 12
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 13
Cgal Bibliography I
The Cgal Project.Cgal User and Reference Manual.Cgal Editorial Board, 4.4 edition, 2014. http://doc.cgal.org/4.2/CGAL.CGAL/html/index.html .Efi Fogel, Ron Wein, and Dan Halperin.Cgal Arrangements and Their Applications, A Step-by-Step Guide.Springer, 2012.
Mario Botsch, Leif Kobbelt, Mark Pauly, Pierre Alliez, and Bruno Levy.Polygon Mesh Processing.CRC Press, 2010.
A. Fabri, G.-J. Giezeman, L. Kettner, S. Schirra, and S. Schönherr.On the design of Cgal a computational geometry algorithms library.Software — Practice and Experience, 30(11):1167–1202, 2000. Special Issue on Discrete AlgorithmEngineering.
A. Fabri and S. Pion.A generic lazy evaluation scheme for exact geometric computations.In 2nd Library-Centric Software Design Workshop, 2006.
M. H. Overmars.Designing the computational geometry algorithms library Cgal.In Proceedings of ACM Workshop on Applied Computational Geometry, Towards GeometricEngineering, volume 1148, pages 53–58, London, UK, 1996. Springer.
Many Many Many papers
Computational Geometry 14
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 15
Some Cgal Commercial Customers
Computational Geometry 16
Cgal Commercial Customers, Geographic Segmentation
Computational Geometry 17
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 18
Cgal Structure
Basic LibraryAlgorithms and Data Structurese.g., Triangulations, Surfaces, and Arrangements
KernelElementary geometric objectsElementary geometric computations on them
Support Library
Configurations, Assertions,...
VisualizationFilesI/O
Number TypesGenerators
Computational Geometry 19
Cgal Kernel Concept
Geometric objects of constant size.Geometric operations on object of constant size.
Primitives 2D, 3D, dD OperationsPredicates Constructions
point comparison intersectionvector orientation squared distancetriangle containment . . .iso rectangle . . .circle
. . .
Computational Geometry 20
Cgal Kernel Affine Geometry
point - origin → vectorpoint - point → vectorpoint + vector → point
point + point ← Illegalmidpoint(a,b) = a+1/2× (b−a)
Computational Geometry 21
Cgal Kernel Classification
Dimension: 2, 3, arbitraryNumber types:
Ring: +,−,×Euclidean ring (adds integer division and gcd) (e.g., CGAL : : Gmpz).Field: +,−,×,/ (e.g., CGAL : : Gmpq).Exact sign evaluation for expressions with roots (F i e l d_w i th_sq r ).
Coordinate representationCartesian—requires a field number type or Euclidean ring if noconstructions are performed.Homegeneous—requires Euclidean ring.
Reference countingExact, Filtered
Computational Geometry 22
Cgal Kernels and Number Types
Cartesian representation Homogeneous representation
point∣∣∣∣ x = hx
hwy = hy
hwpoint
∣∣∣∣∣∣hxhyhw
Intersection of two lines{a1x +b1y + c1 = 0a2x +b2y + c2 = 0
{a1hx +b1hy + c1hw = 0a2hx +b2hy + c2hw = 0
(x ,y) = (hx ,hy ,hw) =∣∣∣∣∣ b1 c1
b2 c2
∣∣∣∣∣∣∣∣∣∣ a1 b1a2 b2
∣∣∣∣∣,−
∣∣∣∣∣ a1 c1a2 c2
∣∣∣∣∣∣∣∣∣∣ a1 b1a2 b2
∣∣∣∣∣
(∣∣∣∣ b1 c1b2 c2
∣∣∣∣ ,− ∣∣∣∣ a1 c1a2 c2
∣∣∣∣ , ∣∣∣∣ a1 b1a2 b2
∣∣∣∣)
Field operations Ring operations
Computational Geometry 23
Cgal Numerical Issues� �#i f 1
t y p ed e f CORE : : Expr NT;t y p ed e f CGAL : : Ca r t e s i a n <NT> Kerne l ;NT sq r t 2 = CGAL : : s q r t (NT( 2 ) ) ;
#e l s et y p ed e f doub l e NT;t y p ed e f CGAL : : Ca r t e s i a n <NT> Kerne l ;NT sq r t 2 = s q r t ( 2 ) ;
#e n d i f
Ke rne l : : Point_2 p (0 , 0 ) , q ( sq r t2 , s q r t 2 ) ;Ke rne l : : C i r c l e_2 C(p , 4 ) ;a s s e r t (C . has_on_boundary ( q ) ) ;� �
OK if NT supports exact sqrt.Assertion violation otherwise.
p
qC
Computational Geometry 24
Cgal Pre-defined Cartesian Kernels
Support construction of points from doub l e Cartesian coordinates.Support exact geometric predicates.Handle geometric constructions differently:
CGAL : : E x a c t_p r e d i c a t e s_ i n e x a c t_ c on s t r u c t i o n s_k e r n e lF Geometric constructions may be inexact due to round-off errors.F It is however more efficient and sufficient for most Cgal algorithms.
CGAL : : E x a c t_p r e d i c a t e s_e x a c t_con s t r u c t i o n s_k e r n e lCGAL : : E x a c t_p r ed i c a t e s_e xa c t_con s t r u c t i o n s_ke r n e l_w i t h_ sq r t
F Its number type supports the exact square-root operation.
Computational Geometry 25
Cgal Special Kernels
Filtered kernels2D circular kernel3D spherical kernel
Refer to Cgal’s manual for more details.
Computational Geometry 26
Cgal Basic Library
Generic data structures are parameterized with TraitsSeparates algorithms and data structures from the geometric kernel.
Generic algorithms are parameterized with iterator rangesDecouples the algorithm from the data structure.
Computational Geometry 27
Cgal Components Developed at Tel Aviv University
2D Arrangements2D Regularized Boolean Set-Operations2D Minkowski Sums2D Envelopes3D Envelopes2D Snap Rounding2D Set Movable Seperability (2D Casting)3D Set Movable Seperability (3D Casting)Inscribed Areas / 2D Largest empty iso rectangleCGAL Python bindings for the above
Computational Geometry 28
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 29
2D Arrangements
Definition (Arrangement)Given a collection C of curves on a surface, the arrangement A(C) is thepartition of the surface into vertices, edges and faces induced by thecurves of C
An arrangement of cir-cles in the plane
An arrangement of lines in theplane
An arrangement ofgreat-circle arcs on asphere
Computational Geometry 30
Arrangement_2<Tra i t s , Dcel>
Is the main component in the 2D Arrangements package.An instance of this class template represents 2D arrangements.The representation of the arrangements and the various geometricalgorithms that operate on them are separated.The topological and geometric aspects are separated.
The T r a i t s template-parameter must be substituted by a model of ageometry-traits concept, e.g., ArrangementBasicTraits_2.
F Defines the type X_monotone_curve_2 that represents x -monotonecurves.
F Defines the type Point_2 that represents two-dimensional points.F Supports basic geometric predicates on these types.
The Dce l template-parameter must be substituted by a model of theArrangementDcel concept, e.g., A r r_de f au l t_dce l <Tra i t s >.
Computational Geometry 31
Arrangement Background
Arrangements have numerous applicationsrobot motion planning, computer vision, GIS, optimization,computational molecular biology
A planar map of the Boston area showing the top of the arm of cape cod.Raw data comes from the US Census 2000 TIGER/line data files
Computational Geometry 32
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 33
Point-Line Duality Transform
Points and lines are transformed into lines and points, respectively.Primal Plane Dual Planethe point p : (a,b) the line p∗ : y = ax −bthe line l : y = cx +d the point l∗ : (c,−d)
This duality transform does not handle vertical lines!
The transform is incidencepreserving.The transform preserves theabove/below relation.The transform preserves thevertical distance between apoint and a line.
k
`pq
r
Primalp∗
q∗ r ∗k∗
`∗ Dual
Computational Geometry 34
Application: Minimum-Area Triangle
Application (Minimum-Area Triangle)Given a set P = {p1,p2, . . . ,pn} of n points in the plane, find three distinctpoints pi ,pj ,pk ∈ P such that the area of the triangle 4pipjpk is minimalamong all other triangles defined by three distinct points in P.
p1
p2
p3
p4
p5
A naive algorithm requires O(n3) time.It is possible to compute in O(n2)time.
The analysis of the algorithmtime-complexity uses the zonecomplexity theorem.
Computational Geometry 35
Application: Minimum-Area Triangle
Application (Minimum-Area Triangle)Given a set P = {p1,p2, . . . ,pn} of n points in the plane, find three distinctpoints pi ,pj ,pk ∈ P such that the area of the triangle 4pipjpk is minimalamong all other triangles defined by three distinct points in P.
p1
p2
p3
p4
p5A naive algorithm requires O(n3) time.
It is possible to compute in O(n2)time.
The analysis of the algorithmtime-complexity uses the zonecomplexity theorem.
Computational Geometry 36
Application: Minimum-Area Triangle
Application (Minimum-Area Triangle)Given a set P = {p1,p2, . . . ,pn} of n points in the plane, find three distinctpoints pi ,pj ,pk ∈ P such that the area of the triangle 4pipjpk is minimalamong all other triangles defined by three distinct points in P.
p1
p2
p3
p4
p5A naive algorithm requires O(n3) time.It is possible to compute in O(n2)time.
The analysis of the algorithmtime-complexity uses the zonecomplexity theorem.
Computational Geometry 37
Minimum Area Triangle: DualityP∗—the set of lines dual to the input points.
P∗ does not contain vertical lines.
p∗i ,p∗j ∈ P∗
`∗ij—the point of intersection betweenp∗i and p∗j .`ij—the line that contains pi and pj .pk—the point that defines theminimum-area triangle with pi and pj .pk is the closest point to `ij =⇒pk is the closest point to `ij in thevertical distance.p∗k—the line immedialy above orbelow the point `∗ij .
pi
pjpk
lij
Primal
l∗ij
p∗i p∗j
p∗k
Dual
Computational Geometry 38
Outline
1 CgalIntroductionContentLiteratureGeometry FactoryDetails
2 ArrangementMinimum Area TriangleSpherical Gaussian Map
Computational Geometry 39
Gaussian Map (Normal Diagram) in 2DDefinition (Gasusian map or normal diagram)The Gaussian map of a convex polygon P is thedecomposition of S into maximal connected arcs so that theextremal point of P is the same for all directions within onearc
~d2
~d1
An arc of directionsbetween ~d1 and ~d2.
⇐⇒
⇐⇒
Generalizes to higher dimensionsComputational Geometry 40
Carl Friedrich Gauss1777–1855
Gasusian Map (Normal Diagram) in 3DDefinition (Gasusian map or normal diagram in 3D)The Gaussian map of a convex polytope P in IR3, denoted as GM(∂P), isthe decomposition of S2 into maximal connected regions so that theextremal point of P is the same for all directions within one region
GM is a set-valued function from ∂P to S2. GM(p ∈ ∂P) = the set ofoutward unit normals to support planes of P at p.
v ,e, f—a vertex, an edge, a facet of PGM(f ) = outward unit normal to fGM(e) = geodesic segmentGM(v) = spherical polygonGM(P) is an arrangement on S2
GM(P) is unique.
If each face GM(v) is extended with v , ⇒ GM−1(GM(P)) = PComputational Geometry 41