Upload
others
View
11
Download
1
Embed Size (px)
Citation preview
Computational Geometry
Efi Fogel
Tel Aviv University
Computational Geometry Algorithm LibraryDec. 14th, 2015
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 2
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
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
Some of Cgal Content
Bounding Volumes Polyhedral Surfaces Boolean Operations
Triangulations Voronoi Diagrams Mesh Generation
Subdivision Simplification Parametrisation Streamlines Ridge Detection Neighbor Search Kinetic Data Structures
Envelopes Arrangements Intersection Detection Minkowski Sums PCA Polytope Distance QP Solver
Computational Geometry 5
Some Cgal Commercial Users
Computational Geometry 6
Cgal Facts
Written in C++
Follows the generic programming paradigm
Development started in 1995
Active European sites:
1 GeometryFactory
2 INRIA Sophia Antipolis
3 INRIA Nancy - GrandEst
4 INRIA Saclay - Île deFrance
5 CNRS - LIRIS
6 CNRS - UniversitéParis–Dauphin
7 Tel Aviv University
8 Assembrix
9 MPII Saarbrücken
10 ETH Zürich
11 Universidade Federal dePernambuco
12 University of Crete andFO.R.T.H.
13 University of California,Davis
14 Universitá della Svizzeraitaliana
15 Universidade Federal doRio de Janeiro
Computational Geometry 7
Cgal History
Year Version Released Other Milestones
1996 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 founded2004 Dec 3.120052006 May 3.22007 Jun 3.32008 CMake
2009 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 20th anniversary 1cm
Computational Geometry 8
Cgal in Numbers
1,600,000 lines of C++ code10,000 downloads per year not including Linux distributions4,500 manual pages3,000 subscribers to cgal-announce list1,000 subscribers to cgal-discuss list
120 packages60 commercial users30 active developers6 months release cycle7 Google’s page rank for www.cgal.org2 licenses: Open Source and commercial
Computational Geometry 9
Cgal Properties
Reliability
Explicitly handles degeneraciesFollows the Exact Geometric Computation (EGC) paradigm
Flexibility
Is an open libraryDepends on other libraries (e.g., Boost, Gmp, Mpfr, Qt, & Core)Has a modular structure, e.g., geometry and topology are separatedIs adaptable to user codeIs extensible, e.g., data structures can be extended
Ease of Use
Has didactic and exhaustive ManualsFollows standard concepts (e.g., C++ and Stl)Characterizes with a smooth learning-curve
EfficiencyAdheres to the generic-programming paradigm
⋆ Polymorphism is resolved at compile time
Computational Geometry 10
Cgal Structure
Basic Library
Algorithms and Data Structurese.g., Triangulations, Surfaces, and Arrangements
Kernel
Elementary geometric objectsElementary geometric computations on them
Support Library
Configurations, Assertions,...
Visualization
Files
I/O
Number Types
Generators
...
Computational Geometry 11
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 12
Cgal Kernel Concept
Geometric objects of constant size.
Geometric operations on object of constant size.
Primitives 2D, 3D, dDOperations
Predicates Constructions
point comparison intersectionvector orientation squared distancetriangle containment . . .iso rectangle . . .circle
. . .
Computational Geometry 13
Cgal Kernel Affine Geometry
point - origin → vectorpoint - point → vectorpoint + vector → point
point + point ← Illegalmidpoint(a,b) = a+1/2× (b−a)
Computational Geometry 14
Cgal Kernel Classification
Dimension: 2, 3, arbitrary
Number 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 representation
Cartesian — requires a field number type or Euclidean ring if noconstructions are performed.Homegeneous — requires Euclidean ring.
Reference counting
Exact, Filtered
Computational Geometry 15
Cgal Kernels and Number Types
Cartesian representation Homogeneous representation
point
∣
∣
∣
∣
x = hxhw
y = hyhw
point
∣
∣
∣
∣
∣
∣
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 c1b2 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 16
Example: Ke rne l s <NumberType>
Ca r t e s i an <FieldNumberType>
t y p e d e f CGAL : : Ca r t e s i an <Gmpq> Kerne l ;t y p e d e f CGAL : : S imp l e_ca r t e s i an <double> Kerne l ;
⋆ No reference-counting, inexact instantiation
Homogeneous<RingNumberType>
t y p d e f CGAL : : Homogeneous<Core : : B ig In t > Kerne l ;
d-dimensional Ca r t e s i an_d and Homogeneous_d
Types + Operations
Kerne l : : Point_2, Ke rne l : : Segment_3Ke rne l : : Less_xy_2, Ke rne l : : Con s t r u c t_b i s e c t o r_3
Computational Geometry 17
Cgal Numerical Issues✞ ☎
t y p e d e f CGAL : : Ca r t e s i an <NT> Kerne l ;NT s q r t 2 = s q r t (NT( 2 ) ) ;
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 18
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 o n s t r u c t i o n s _ k e r n e l
⋆ Geometric constructions may be inexact due to round-off errors.⋆ 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 _ c o n s t r u c t i o n s _ k e r n e lCGAL : : E x a c t _ p r e d i c a t e s _ e x a c t _ c o n s t r u c t i o n s _ k e r n e l _ w i t h _ s q r t
⋆ Its number type supports the exact square-root operation.
Computational Geometry 19
Cgal Special Kernels
Filtered kernels
2D circular kernel
3D spherical kernel
Refer to Cgal’s manual for more details.
Computational Geometry 20
Computing the Orientationimperative style✞ ☎#i n c l u d e <CGAL/ E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l . h>
t y p e d e f CGAL : : E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l Ke rne l ;t y p e d e f Ke rne l : : Point_2 Point_2 ;
i n t main ( ){
Point_2 p ( 0 , 0 ) , q ( 1 0 , 3 ) , r ( 1 2 , 1 9 ) ;r e t u r n (CGAL : : o r i e n t a t i o n ( q , p , r ) == CGAL : : LEFT_TURN) ? 0 : 1 ;
}✝ ✆
precative style✞ ☎#i n c l u d e <CGAL/ E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l . h>
t y p e d e f CGAL : : E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l Ke rne l ;t y p e d e f Ke rne l : : Point_2 Point_2 ;t y p e d e f Ke rne l : : O r i e n t a t i o n _ 2 O r i e n t a t i o n _ 2 ;
i n t main ( ){
Ke rne l k e r n e l ;O r i e n t a t i o n _ 2 o r i e n t a t i o n = k e r n e l . o r i e n t a t i o n _ 2 _ o b j e c t ( ) ;
Point_2 p ( 0 , 0 ) , q ( 1 0 , 3 ) , r ( 1 2 , 1 9 ) ;r e t u r n ( o r i e n t a t i o n ( q , p , r ) == CGAL : : LEFT_TURN) ? 0 : 1 ;
}✝ ✆
Computational Geometry 21
Computing the Intersection
✞ ☎#i n c l u d e <CGAL/ E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l . h>#i n c l u d e <CGAL/ i n t e r s e c t i o n s . h>
t y p e d e f CGAL : : E x a c t _ p r e d i c a t e s _ i n e x a c t _ c o n s t r u c t i o n s _ k e r n e l Ke rne l ;t y p e d e f Ke rne l : : Point_2 Point_2 ;t y p e d e f Ke rne l : : Segment_2 Segment_2 ;t y p e d e f Ke rne l : : L ine_2 Line_2 ;
i n t main ( ) {Point_2 p ( 1 , 1 ) , q ( 2 , 3 ) , r ( −12 ,19) ;Line_2 l i n e ( p , q ) ;Segment_2 seg ( r , p ) ;auto r e s u l t = CGAL : : i n t e r s e c t i o n ( seg , l i n ) ;i f ( r e s u l t ) {
i f ( c o n s t Segment_2∗ s = boos t : : get<Segment_2>(&∗ r e s u l t ) ) {// hand l e segment
}e l s e {
c o ns t Point_2∗ p = boos t : : get<Point_2 >(&∗ r e s u l t ) ;// hand l e p o i n t
}}r e t u r n 0 ;
}✝ ✆
Computational Geometry 22
Cgal Basic Library
Generic data structures are parameterized with Traits
Separates algorithms and data structures from the geometric kernel.
Generic algorithms are parameterized with iterator ranges
Decouples the algorithm from the data structure.
Computational Geometry 23
Cgal Components Developed at Tel Aviv University
2D Arrangements
2D Regularized Boolean Set-Operations
2D Minkowski Sums
2D Envelopes
3D Envelopes
2D Snap Rounding
Inscribed Areas / 2D Largest empty iso rectangle
Computational Geometry 24
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 25
Cgal Bibliography
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.
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.
Computational Geometry 26
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 27
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 28
Application: Art Gallery
Application (Art Gallery)
Given the floor plan of an art gallery modeled as a simple polygon with nvertices. Find out how many (and where) guards are needed to see theentire gallery, where each guard is stationed at a fixed point, has 360◦
vision, and cannot see through the walls.
Problem posed to Vasek Chvatal by Victor Klee at a math
conference in 1973. Chvatal solved it quickly with a
complicated proof, which has since been simplified
significantly using triangulation.
Computational Geometry 29
Art Gallery in IR3
Even n-vertex guards do not suffice!
Different triangulations can have different number of tetrahedra.
Determining whether a polyhedron requires Steiner vertices fortriangulation is NP-Complete.
Smallest example of a polyhedron that cannot be triangulated withoutadding new vertices. (Schoenhardt [1928]).
Every 3D polyhedron with n vertices can be triangulated with O(n2)tetrahedra. [Cha84]
5 tetrahedra 6 tetrahedra
Computational Geometry 30
3D Printing
A picture is worth a thousand words,but An object is worth a thousand pictures.
Computational Geometry 31
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 32
Model Decomposition into Lego Bricks
Computational Geometry 33
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 34
Movies
Eyal Flato, Efi Fogel, Dan Halperin, and Eyal Leiserowitz.
Movie: Exact Minkowski Sums and Applications.In Proceedings of 18th Annual ACM Symposium on Computational Geometry (SoCG), pages 273–274. Association forComputing Machinery (ACM) Press, 2005.
Efi Fogel and Dan Halperin.
Movie: Exact Minkowski sums of convex polyhedra.In Proceedings of 21st Annual ACM Symposium on Computational Geometry (SoCG), pages 382–383. Association forComputing Machinery (ACM) Press, 2005.
Efi Fogel, Ophir Setter, and Dan Halperin.
Movie: Arrangements of Geodesic Arcs on the Sphere.In Proceedings of 24th Annual ACM Symposium on Computational Geometry (SoCG), pages 218–219. Association forComputing Machinery (ACM) Press, 2008.
Computational Geometry 35
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 36
Movable Separability
Computational Geometry 37
Terms & Definitions
Assembly — A collection of pairwise interior disjoint bodies/parts, sayA.
Subassembly — A subset of parts of A in their relative placements in A.
Assembly Operation — A motion that merges s subassemblies of A into anew subassembly; s is the number of hands.
Assembly Partitioning — The reverse of Assembly Operation(disassembly).
Assembly Sequence — A total ordering of assembly operations fromseparated parts to the full A.
Monotone Operation — An operation that generates only subassembliesof the final A.
Computational Geometry 38
Constraints
We will discuss assembly planning problems constrained to
2-handed
Monotone operations
Rigid parts
Hence, we can plan assembly by disassembly.
Computational Geometry 39
Partitioning with Convex Parts
In IR2
Admit a disassembly sequence translating one part at a time along afixed (arbitrary) direction to infinity.
In IR3
Depth order does not always exists.Moreover, assemblies of convexparts may be interlocked.
[SS93]
Computational Geometry 40
2-Handed Assembly by Disassembly
Input: an assmebly A, the allowable motions.
Output: an assembly sequence.
algorithm:
Partition A, and then the two subassemblies recursively, or stop andannounce failure.reverse the disassembly motions into an assembly sequence.
Computational Geometry 41
Polyhedral Assembly Partitioning with Infinite Translations
Input: n pairwise interior disjoint polytopes in IR3
A = {P1,P2, . . . ,Pn}
Output: A proper subset S ⊂ A and a direction ~d in IR3,
S can be translated as a rigid body to infinity along ~dwithout colliding with A\SSliding motions of parts over other parts are allowed
Computational Geometry 42
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 43
Motion Planning: A Translating Polygonal Robot
Application (A Translating Polygonal Robot)
Given a simple-polygon robot Q, which can translate (but not rotate) in aroom cluttered with pairwise interior-disjoint polygonal obstacles, devise adata structure that can efficiently answer queries of the following form:Given a start position s of some reference point in Q and a goal position gof the same reference point, plan a collision-free path of the robot from sto g.
s g
Computational Geometry 44
Motion Planning: A Translating Polygonal Robot (cont.)
The workspace:
a diamond-shaped robot translating in
a house amidst polygonal obstacles
The configuration space:
the forbidden-configuration space,
the free-configuration space
decomposed into trapezoidal faces
the queries, and the resulting paths, if
exist.
Computational Geometry 45
Outline
1 Cgal
IntroductionContentLiterature
2 ExtraArt GalleryLego DecompositionMinkowski SumsAssembly PartitioningMotion PlanningLiterature
Computational Geometry 46
Triangulation Bibliography I
B. Chazelle.Triangulating a Simple Polygon in Linear Time.Discrete and Computational Geometry, 6:485–524,1991.
M. R. Garey, D. S. Johnson, F. P. Preparata, and R. E. Tarjan.Triangulating a Simple Polygon.Information Processing Letter, 7(4): 175-180, 1978.
R. E. Tarjan and C. J. van Wyk.An O(n log log(n)) Time Algorithm for Triangulating a Simple Polygon.SIAM Journal of Computing, 17(1):143-178, 1988.
Mark de Berg, Mark van Kreveld, Mark H. Overmars, and Otfried Cheong.Computational Geometry: Algorithms and Applications.Springer, 3rd edition, 2008. Chapter 3: Polygon Triangulation.
Alexey V. Skvortsov, Yuri L. KostyukEfficient algorithms for Delaunay triangulation.Geoinformatics. Theory and practice (Tomsk State University) 1: 22–47, 1998.
Bernard Chazelle.Convex partitions of polyhedra: a lower bound and worst-case optimal algorithm.SIAM Journal on Computing, 13:488–507, 1984.
Michael J. Laszlo.Computational Geometry and Computer Graphics in C++.Prentice-Hall, 1996
Computational Geometry 47
Assembly Partitioning Bibliography I
Jack Snoeyink and Jorge Stolfi,Objects that cannot be taken apart with two hands,In Proceedings of 9th ACM Annual Symposium on Computational Geometry, pages 247–256, 1993.
Randall H. Wilson and Jean-Claude Latombe,Geometric reasoning about mechanical assembly,Artificial Intelligence, 71(2):371–396, 1994.
Lydia E. Kavraki and Mihail N. Kolountzakis,Partitioning a planar assembly into two connected parts is NP-complete,Information Processing Letters, 55:159–165, 1995.
Randall H. Wilson, Lydia E. Kavraki, Tomás Lozano-Pérez, and Jean-Claude Latombe,Two-handed assembly sequencing,International Journal of Robotics Research, 14:335–350, 1995.
Sanjeev Khanna, Rajeev Motwani, and Randall H. Wilson,On certificates and lookahead in dynamic graph problems,Algorithmica, 21(4):377–394, 1998.
Dan Halperin, Jean-Claude Latombe, and Randall H. Wilson,A general framework for assembly planning: The motion space approach,Algorithmica, 26:577–601, 2000.
Efi Fogel and Dan Halperin,Polyhedral Assembly Partitioning with Infinite Translations or The Importance of Being Exact,IEEE TASE Automation Science and Engineering, 10(2): 227–241, 2013.
and more ...
Computational Geometry 48