Computational Geometry · 2005-02-27 · Why Computational Geometry? Science and theory • Natural...
Transcript of Computational Geometry · 2005-02-27 · Why Computational Geometry? Science and theory • Natural...
1
Computational GeometryComputational GeometryCSCS course 67599course 67599 –– Spring 2005Spring 2005
LecturerLecturer:: Prof. Leo JoskowiczProf. Leo Joskowicz
TATA: Yaron Ostrovsky: Yaron Ostrovsky--BermanBerman
Web page: Web page: http://http://www.cs.huji.ac.il/~compgeomwww.cs.huji.ac.il/~compgeom//Lecture: Mon 12Lecture: Mon 12––14 14 ShprinzakShprinzak 2626Exercise: Wed 11Exercise: Wed 11––12 12 ShprinzakShprinzak 202202Office hours: Mon 10Office hours: Mon 10--12 (L), Wed 1012 (L), Wed 10--11 (E) or by appointment11 (E) or by appointment
2Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Copyright noticeCopyright notice• These slides were prepared based on material
generously contributed by: • Prof. Gill Barequet
• Prof. Craig Gotsman
Center for Graphics and Geometric Computation,
Dept. of Computer Science, Technion.
• The use of for the class only. Please do NOT distribute to other parties. Only PDF files are provided.
• Slides are bound to change and are a teaching aid. They are not complete!
3Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
BooksBooks
4Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
BooksBooks
• Computational Geometry: Algorithms and Applications M. de Berg, M. van Kreveld, M. Overmars, O. Schwarzkopf, 2nd edition, Springer-Verlag, 2000.
• Computational Geometry in CJ. O’Rourke, 2nd edition, Cambridge Univ. Press, 2000.
• Course slides
5Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Additional booksAdditional books
6Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Course logisticsCourse logistics• Prerequisites: Data Structures
• Parallel courses: Algorithms A and B
• Related courses: Computer Graphics, Computer-Aided Design Vision, Robotics, Image Processing,
• Grading:
• 50% final written exam, closed books, 3 hours.
• 50% 5 out of 6 homeworks, theoretical, equal weight, assigned every 2 weeks, individual. Five exercises are mandatory. Penalty for late handing in: 5 points/day to a maximum of 5 days.
7Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
CouseCouse syllabus syllabus –– Lectures Lectures 1. Introduction – Motivation, geometric preliminaries
2. Convex hulls in 2D and 3D
3. Line and segment intersection problems
4. Polygon triangulation and decomposition
5. Orthogonal range searching
6. Point location
7. Voronoi diagrams
8. Linear programming, duality, and arrangements
9. Motion planning, Minkowski sums
8Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Planned course schedule (1)Planned course schedule (1)1. 21.2 Lecture 1: Preliminaries
23.2 Exercise2. 28.2 Lecture 2: Convex Hull 2D+3D
02.3 Exercise – HW 1 handed.3. 07.3 Lecture 3: Sweep line, intersections, map overlay
09.3 Exercise4. 14.3 Lecture 4: Triangulation, polygon decomposition
16.3 Exercise – HW1 due. HW2 handed.5. 21.3 Lecture 4: Polygon descomposition
23.3 Exercise 6. 28.3 Lecture 5: Orthogonal range queries
30.3 Exercise – HW2 due. HW3 handed.7. 04.4 Lecture 5: Orth. range queries (cont.) Point location
06.4 Exercise8. 11.4 Lecture 6: Point location
13.4. Exercise. HW3 due. HW4 handed
9Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Planned Planned cousecouse scheduleschedule ) ) 22 ( (-------- 17.4.05 – 29.4.05 Passover vacation -----------------------9. 02.5 Lecture 7: Voronoi Diagrams
04.5 Exercise10. 09.5 Lecture 7: Voronoi Diagrams (continued)
11.5 No Exercise (Memorial Day) HW4 due. HW5 handed.11. 16.5 Lecture 8: Linear programming, Duality
18.5 Exercise12. 23.5 Lecture 8: Arrangements
25.5 Exercise: HW5 due. HW6 handed.13. 30.5 Lecture 9: Minkowski sums, motion planning
01.6 Exercise14. 06.6 Lecture 9: Motion planning
08.6 Exercise HW6 due. 15. 13.6 Shavuot – No Lecture
15.6 Exercise: Review for exam
10Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Course style and scopeCourse style and scopeGoals
• Present a balanced introductory account which includes theory and practice.
• Detailed coverage of the basic techniques, including combinatorial, algorithmic and practical issues.
• Selected advanced topics and recent results
• Mostly 2D, some 3D when appropriate.
11Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Lecture 0Lecture 0• What is Computational Geometry (CG)?
• Examples of typical CG problems
• CG in perspective
• Preliminaries• Basic geometry concepts
• Polygons: definition and representation
• Polyhedra: definition and representation
12Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
What is Computational Geometry?What is Computational Geometry?The study of algorithms for solving geometric problems
• Geometry: • a set of geometric primitives (points, lines, curves,
planes, surfaces) defined in a metric space, usually in the plane (2D) or in space (3D).
• A set of geometric operations (intersection, union, decomposition) on geometric entities.
• Algorithms:• Constructive procedures to compute properties,
answer queries, or construct geometric entities.
13Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
What is Computational Geometry?What is Computational Geometry?
• Complexity: • Analysis to gain an understanding of what can
and cannot be achieved, and with what degree of difficulty.
• Algorithmic flavor:• Topological (combinatorial) component
• Geometric component
14Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Why Computational Geometry?Why Computational Geometry?Science and theory
• Natural continuation of the constructive geometry and combinatorial geometry schools in Mathematics.
• A branch of theoretical Computer Science.• Important relation to fundamental problems in
mathematics: linear programming, algebraic geometry
Technology and applications• Many key problems in Engineering and Graphics.• Develop libraries of efficient and robust algorithms.• Understanding of specialized problems.• Great economic importance: Graphics, CAD/CAM, …
15Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Examples of CG problemsExamples of CG problems
• Nearest neighbor
• Voronoi diagram
• Point location
• Point in polygon
• Range searching and counting
• Shortest path
• Visibility
16Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Nearest neighborNearest neighborProblem definition
• Input: a set of points (sites) P in the plane and a query point q.
• Output: The point p∈P closest to q among all points in P.
Variations• One point set, multiple queries
• Dynamic point, dynamic point set
• In 3D instead of 2D
Applications: cellphones, store location.
P
qp
17Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
VoronoiVoronoi diagramdiagramProblem definition
• Input: a set of points (sites) P in the plane.
• Output: A planar subdivision Sinto cells per site. The cell corresponding to p∈P contains all the points to which p is the closest.
S
P
Variations• Dynamic point set
Applications: site coverage, best location of new site.
18Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Point locationPoint locationProblem definition
• Input: A partition S of the plane into cells and a query point p.
• Output: The cell C ∈ Scontaining p.
Variations• One partition, multiple queries
Applications: Nearest neighbor, locator.
S
p
C
19Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Point in polygonPoint in polygon
P
Problem definition• Input: a polygon P in the plane and
a query point p.
• Output: true if p∈P, else false.
Variations• One polygon, multiple queries
Applications: region location
p
20Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
P
Range searching and countingRange searching and countingProblem definition
• Input: A set of points P in the plane and a query rectangle R
• Output: (report) The subset Q ⊆ P
contained in R.
(count) The size of Q.R
Q
Variations• One point set, multiple queries.
• Spatial
Application: Urban planning.
21Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Shortest pathShortest pathProblem definition
• Input: Obstacles locations and query endpoints s and t.
• Output: the shortest path between s and t that avoids all obstacles.
Variations• One obstacle set, multiple queries.
• Multiple targets, moving obstacles
Application: Routing, robotics.
s
t
22Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
VisibilityVisibilityProblem definition
• Input: a polygon P in the plane and a query point p.
• Output: Polygon Q ⊆ P, visible to p.
Variations• One polygon, multiple queries
• Multiple polygons, 3D
Applications: rendering, security
P
p
Q
23Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Very brief and partial historical viewVery brief and partial historical viewGeometry is one of the oldest sciences!!
• Euclid constructions in The Elements• Descartes Cartesian geometry• 19th and 20th century geometry: formulation of
algebras and geometries (Gauss, Hilbert, Galois)• Computability, completeness, complexity
Practical interest in 50’s, with the computer• first graphics program: hidden line removal• CAD drafting programs• CNC machining
24Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Very brief and partial historical viewVery brief and partial historical viewScattered work in the 60’s and 70’s
• Bezier splines for surface modeling
• Graphics algorithms for 3D display
• Combinatorial math. works (Erdös et al.)
Official name in 1975 in Shamos’ seminal thesis: Problems in Computational Geometry
Increased theoretical interest in the 70’s and 80’s • Basic algorithms, complexity issues: O’Rourke, Yap,
Chazelle. Motion planning: Schwartz and Sharir.
Active and growing field in the 90’s and now• Bridge between theory and practice, robustness, randomization
25Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Geometric preliminariesGeometric preliminariesEuclidean space: Ed
• Space of d-tuples, p = (x1,…,xd), of real numbers x1 ε R
called points, where d is the space dimension.
• Metric: a function m: Ed × Ed R with three properties:
1. m(p,p) = 0 identity
2. m(p1,p2) = m(p2,p1) symmetry
3. m(p1,p2) ≤ m(p2,p1) + m(p2,p1) triangle inequality
• Distance metric: function from Ed × Ed R such that
∑ =−=−=
d
i ii pxpxppppd1
2/1 2212121 ))()((||||),(
26Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Geometric primitivesGeometric primitivesPoint: tuples p = (x1,…,xd) are defined with respect to a
common origin frame. Also interpreted as vectors.
• Line: a linear combination of two distinct points
• Line segment: bounded line
• Plane: a linear combination of d points
• Linear variety: as above for k ≤ d.
Rpp ∈−+ ααα )1( 21
11
)...1(... 11112211
−≤≤ℜ∈−−−++++ −−−
dj
pppp
j
dddd
αααααα
]1,0[)1( 21 ∈−+ ααα pp
27Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
SetsSets• A set of points S is connected if it is not the union of
two non-empty sets.
• The boundary of a set S is a subset of points for which there exists a neighbor point at distance ε 0 that is not in S.
• Jordan curve theorem: every simple closed curve (no self intersections) partitions the plane into two disjoint regions. The exterior is unbounded, the interior is bounded.
exteriorexterior
interiorinteriorp1
p2
28Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Convex setConvex set• A subset S of Ed is convex iff for all p1, p2 in S
all the points in the line segment p1p2 are in S.
CONVEX NOT CONVEX
• Theorem: the intersection of convex sets is convex.
p1
p2
p1
p2
p1
p2
29Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Convex hullConvex hull• The convex hull CH(P) of a set of points P in Ed is the
smallest convex set containing P.
Equivalent: the intersection of all convex sets that contain S.
• Property: the convex hull is bounded by line segments (planes).
CH(P)
P
30Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
PolygonsPolygonsDefinition: a polygon is the region of the plane bounded
by a finite collection of line segments (edges) forming simple closed curves where every segment endpoint (vertex) is shared exactly by two edges.
edges edges eeij==(vi,vI)
vertices vertices vvi==(xi,yi)
boundariesboundariesExamples:Examples:NonNon--polygonspolygonsPolygon complexity: # of verticesPolygon complexity: # of vertices
31Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Types of polygons (1)Types of polygons (1)Simple polygon: a single closed boundary curve:
1. No pair of non-consecutive edges share a vertex
2. Non-adjacent edges do not intersect.
Convex polygon: No line between any two vertices is outside the polygon (to prove as an exercise).
diagonalsdiagonals
32Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Types of polygons (2)Types of polygons (2)Star-shaped polygons: a simple polygon P such that there
exits a point p in its interior so that all lines from p to any point q in P is inside P.
Monotone polygon: a polygon P is monotone along a line L iff the projection of its vertices on the line is order-preserving.
AxisAxis--aligned polygonaligned polygon
p P
1
2
3
45
6
7
33Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Polygon decompositionsPolygon decompositions• Polygon triangulation: a decomposition of a polygon S
into triangles Ti such that the union of all triangles is Sand triangles only intersect at their edges and vertices.
• Polygon convex decomposition: same as above, with convex polygons instead of triangles.
34Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Graph embedding and subdivisionsGraph embedding and subdivisions• A graph is embedded in Rd if each vertex is
assigned a position in Rd.
• A graph G=(V,E) is planar iff it can be embedded in the plane with no edge crossings.
Embedding in R2 Embedding in R3
35Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Planar graphs and planar subdivisionsPlanar graphs and planar subdivisions• Every planar graph can be drawn as a straight-line
plane graph.
• Polygon triangulations are planar subdivisions that can be represented by a straight line planar graph whose faces are all triangles
A
B
C
D
A
B
C
D
Planar graph Plane graph
A
B
C
D
Straight line plane graph
36Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
EulerEuler’’s Formulas Formula• For a connected planar
graph with E edges, Vvertices, and F faces, the following relation holds:
V– E + F = 2• Theorem: In a planar graph
E = O(V) and F = O(V).
(proof later in the course)
V = 9E = 9F = 2
37Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Line segment representationLine segment representationRepresentation of a line segment with 4 reals
• Two endpoints, p1 and p2
• One endpoint, p1, a slope α,and a length d
• One endpoint p1, a vector direction v and a length interval t
• Other options…• Unique representation?
Different representations may affect the running times of algorithms!
p1
p2
d
αv
38Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Polygon representationPolygon representation• An ordered list of n vertices v0 , …,vn-1 and edges
e i = (vi ,v (i+1) mod n )
• To determine if it is solid (exterior) or hole (interior), assume clockwise (CW) or counterclockwise (CCW) order. The exterior is always to the right of the edge when traversing the boundary.
CWCWv0v9
v8v7
v5
v4v3
v2
v1
v6
CCWCCWv0v1
v2v3
v4v5
v6v7
v8
v9
39Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
PolyhedronPolyhedronA polyhedron is defined by
• a finite set of polygons (called faces) in space such that every edge of a polygon is shared by exactly one other polygons.
• Polygons do not intersect except at edges and vertices
• Polygons define a closed surface
facesfaces
40Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
MeshesMeshes• The surface of a polyhedron is a planar subdivision.
• A mesh is a straight-line graph embedded in R3.
• Boundary edge: adjacent to exactly one face.
• Regular edge: adjacent to exactly two faces.
• Singular edge: adjacent to more than two faces.
• Closed mesh: mesh with no boundary edges.
• Manifold mesh: mesh with no singular edges.
• Every manifold mesh is planar !!
41Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Head: manifold mesh
Meshes: examplesMeshes: examples
Flattened: planar subdivision
42Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Types of meshesTypes of meshes
Manyfoldwith boundary
Non-manyfold
Closed manyfold
43Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
TopologyTopology
Euler-Poincare Formula
For a planar graph:v+f-e = 2(c-g)-b
v = # vertices c = # conn. comp.f = # faces g = genuse = # edges b = # boundaries
A
B C
D
E
I
F
L
K
J
H
G
v =12f = 14e = 25c = 1g = 0b = 1
The genus of a graph is half ofthe maximal number of closed paths
that do not disconnect the graph(the number of “holes”).
Genus(sphere) = 0Genus(torus) = 1
44Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Topology: examplesTopology: examples
Genus 0 Genus 1
Genus 2
45Leo Joskowicz, Spring 2005Leo Joskowicz, Spring 2005
Other geometric entitiesOther geometric entities• Algebraic entities (not covered, CAGD)
• Curves, splines, …• Surface patches, Bézier surfaces, …• Algebraic hypersurfaces
• Why only points, lines and planes?• Relatively simple local computations (intersection,
union, etc)• Focus om global computations and their
combinatorial structure• Understand first simple entities in-depth• Many algorithms serve as the basis for extensions