This course is a gentle introduction to the set of notions useful in geometry processing that I consider as the “minimal toolbox”. I will illustrate the different notions with tips and tricks on how to efficiently implement them in a computer.
Code and demos related to the notions that I’ll present is available in Geogram (https://github.com/BrunoLevy/geogram) and Graphite (https://github.com/BrunoLevy/GraphiteThree)
Syllabus:
1. The hitch hacker’s guide to geometry processing (introduction)
2. Packing your luggage (data structures)
3. Finding your way (geometric search data structures)
4. Connecting with friends (Delaunay and Voronoi)
5. Into darkness (geometric predicates)
6. Planning your next trip (how Geometry Processing can help other scientific disciplines)
4. 01/07/2023
-
Syllabus
>1. The hitch hacker’s guide
to geometry processing
>2. Packing your luggage
>3. Finding your way
>4. Connecting with friends
>5. Into darkness
>6. Planning your next trip
4
10. 1979 Apple ][
6502 processor, 1MHz
64Kb RAM
Approx. 10 FLOPs
2023 PC
Core i7 gen4, 3 GHz
16Gb RAM
Approx. 300 GFLOPs
X 3 million !!!!
44 years
> 1. Hitch hacker’s guide to G.P.
11. Boots in 20 seconds Boots in 3 minutes
> 1. Hitch hacker’s guide to G.P.
12. Boots in 20 seconds Boots in 3 minutes
Where did the 3 million acceleration factor go ?
> 1. Hitch hacker’s guide to G.P.
13. What can you do in 20 seconds ?
3 GHz, 4 cores = 240 billions instructions !!
> 1. Hitch hacker’s guide to G.P.
14. If you cannot do the job in less than 20 seconds
on a modern PC, then there is probably a
problem somewhere
What can you do in 20 seconds ?
3 GHz, 4 cores = 240 billions instructions !!
> 1. Hitch hacker’s guide to G.P.
15. Boots in 20 seconds Boots in 3 minutes
Where did the 1 million acceleration factor go ?
- Lost in abstraction -
> 1. Hitch hacker’s guide to G.P.
16. Abstraction in Programming:
+ Separates concepts
+ Separates specification from Implementation
> 1. Hitch hacker’s guide to G.P.
17. Abstraction in Programming:
+ Separates concepts
+ Separates specification from Implementation
- Sometimes separates things
that should be considered together !!
> 1. Hitch hacker’s guide to G.P.
19. • Jonathan Shewchuk s Triangle and exact predicates
• Tetgen, MGTetra, MMG3d
• Omar Cornut s ImGUI library
• David Mount s ANN library
• The LUA prog. language
Futuristic programming
Examples of Futuristic codes
Usefullness (and coolness) are primary !
> 1. Hitch hacker’s guide to G.P.
21. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
22. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
23. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
24. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
25. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
6. Minimize number of lines of code
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
26. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
6. Minimize number of lines of code
7. Minimize number of C++ classes
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
27. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
6. Minimize number of lines of code
7. Minimize number of C++ classes
Geogram/Graphite Programming Priorities
Simplicity is the
ultimate sophistication
> 1. Hitch hacker’s guide to G.P.
28. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
6. Minimize number of lines of code
7. Minimize number of C++ classes
Geogram/Graphite Programming Priorities
Simplicity is the
ultimate sophistication
> 1. Hitch hacker’s guide to G.P.
29. 1. Make it as simple as possible (but not simpler)
2. Make it as easy to use as possible
3. Make it as easy to compile as possible
4. Maximize speed
5. Minimize memory consumption
6. Minimize number of lines of code
7. Minimize number of C++ classes
8. Systematically document all classes, all functions, [+Biblio.]
9. Systematically document the implementation of all algorithms
10. Assertion checks everywhere
11. Zero warnings with all compilers / platforms
12. Perform systematic non-regression testing and mem.
check.
Geogram/Graphite Programming Priorities
> 1. Hitch hacker’s guide to G.P.
32. From several Computer Graphics / Mesh Processing 101 courses
- including (earlier versions of) mine -
> 2. Packing your luggage ….
…. data structures
33. Halfedges Design Principles
1. Individual combinatorial elements
can be created/destroyed at any time
in constant time
2. Basic operations (collapse, split, )
3. Higher-level operations on top of them
Halfedges and edgeuses, harmful or useful ?
> 2. Packing your luggage ….
…. data structures
34. + Benefit of abstraction: layered design
Halfedges Design Principles
1. Individual combinatorial elements
can be created/destroyed at any time
in constant time
2. Basic operations (collapse, split, )
3. Higher-level operations on top of them
Halfedges and edgeuses, harmful or useful ?
> 2. Packing your luggage ….
…. data structures
35. + Benefit of abstraction: layered design
- Separates things that should have been considered together
Halfedges and edgeuses, harmful or useful ?
Halfedges Design Principles
1. Individual combinatorial elements
can be created/destroyed at any time
in constant time
2. Basic operations (collapse, split, )
3. Higher-level operations on top of them
> 2. Packing your luggage ….
…. data structures
36. + Benefit of abstraction: layered design
- Separates things that should have been considered together
Not the optimal level of granularity
Halfedges and edgeuses, harmful or useful ?
Halfedges Design Principles
1. Individual combinatorial elements
can be created/destroyed at any time
in constant time
2. Basic operations (collapse, split, )
3. Higher-level operations on top of them
> 2. Packing your luggage ….
…. data structures
37. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
38. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
39. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
40. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
41. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
42. Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
43. Objection ! (?) Deletion of one individual element is O(n) instead of constant
In fact: deleting 1 element = wrong granularity level !
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
44. Deleting a bunch of elements
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
45. Deleting a bunch of elements
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
46. Deleting a bunch of elements
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
47. Deleting a bunch of elements – operates also in O(n) – right granularity
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
48. Deleting a bunch of elements – operates also in O(n) – right granularity
Needs array permutation (not in the STL unfortunately,
but easy to implement, see GEOGRAM::permutation).
Indexed Mesh data structure (no data structure)
> 2. Packing your luggage ….
49. Indexed Mesh data structure (no data structure)
Summary:
•An array of vertices coordinates
•An array of triangle vertices indices
> 2. Packing your luggage ….
50. •An array of vertices coordinates
•An array of triangle vertices indices
•An array of triangle adjacencies (optional)
•An array of facet first indices (optional)
Indexed Mesh data structure (no data structure)
Summary:
> 2. Packing your luggage ….
51. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
> 2. Packing your luggage ….
…. data structures
52. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
> 2. Packing your luggage ….
…. data structures
53. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
3. Parallelization #pragma omp parallel for
> 2. Packing your luggage ….
…. data structures
54. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
3. Parallelization #pragma omp parallel for
4. Easy copy: memcpy()
> 2. Packing your luggage ….
…. data structures
55. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
3. Parallelization #pragma omp parallel for
4. Easy copy: memcpy()
5. Easy I/O: fread()/fwrite()
> 2. Packing your luggage ….
…. data structures
56. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
3. Parallelization #pragma omp parallel for
4. Easy copy: memcpy()
5. Easy I/O: fread()/fwrite()
6. Properties/attributes are simply additional arrays
> 2. Packing your luggage ….
…. data structures
57. Benefits of such a
non-datastructure, non-object, non-oriented, (non-)programming
1. Simpler code
2. Less memory;
3. Parallelization #pragma omp parallel for
4. Easy copy: memcpy()
5. Easy I/O: fread()/fwrite()
6. Properties/attributes are simply additional arrays
7. Directly understood by OpenGL: VertexBufferObject
> 2. Packing your luggage ….
…. data structures
58. A mesh = a bunch of arrays (std::vectors)
> 2. Packing your luggage ….
…. data structures
59. A mesh = a bunch of arrays (std::vectors)
How do you iterate on a vector ?
> 2. Packing your luggage ….
…. data structures
61. Pre-2011:
for(std::vector<Thing>::iterator it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
How do you iterate on a vector ?
It s a pain to type
Clutters the source-code (less legible)
> 2. Packing your luggage ….
…. data structures
62. Pre-2011:
for(std::vector<Thing>::iterator it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
2011:
for(auto it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
How do you iterate on a vector ?
> 2. Packing your luggage ….
…. data structures
63. Pre-2011:
for(std::vector<Thing>::iterator it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
2011:
for(auto it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
now:
for(auto&& i : V) {
do something with i
} How do you iterate on a vector ?
> 2. Packing your luggage ….
…. data structures
64. A mesh = a bunch of arrays (std::vectors)
How do you iterate on a vector ?
Warning: flying tomatoes alert ahead,
(modern C++ lovers might throw tomatoes at me)
!
> 2. Packing your luggage ….
…. data structures
65. Pre-2011:
for(std::vector<Thing>::iterator it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
2011:
for(auto it = V.begin(); it!=V.end(); ++it) {
do something with *it
}
now:
for(auto&& i : V) {
do something with I
} How do you iterate on a vector ?
> 2. Packing your luggage ….
…. data structures
66. How I iterate on a vector:
for(uint i=0; i<V.size(); ++i) {
do something with V[i];
}
How do you iterate on a vector ?
> 2. Packing your luggage ….
…. data structures
67. How I iterate on a vector:
for(uint i=0; i<V.size(); ++i) {
do something with V[i];
}
+ Easy to understand, even by C-only and Fortran programmers
+ Compatible with all compilers
+ #pragma omp parallel-for friendly* (and also better vectorization)
- 15 additional keystrokes as compared to modern C++ range-for
How do you iterate on a vector ?
*But use ints instead of uints, omp does not like uints
> 2. Packing your luggage ….
…. data structures
68. How I iterate on a vector:
for(uint i=0; i<V.size(); ++i) {
do something with V[i];
}
+ Easy to understand, even by C-only programmers
+ Compatible with all compilers
+ #pragma omp parallel-for friendly
- 15 additional keystrokes as compared to modern C++ range-for
The following code has been approved for
APPROPRIATE AUDIENCES
PG-13
> 2. Packing your luggage ….
…. data structures
69. How I iterate on a vector:
for(uint i=0; i<V.size(); ++i) {
do something with V[i];
}
+ Easy to understand, even by C-only programmers
+ Compatible with all compilers
+ #pragma omp parallel-for friendly
- 15 additional keystrokes as compared to modern C++ range-for
#define FOR(i,N) for(uint i=0; i<(N); ++i)
FOR(i,V.size()) {
do something with V[i];
}
+ Easy to understand, legible
+ Trivial iterations easy to spot
- Macros are evil
[Nicolas Ray]
> 2. Packing your luggage ….
…. data structures
70. Objection:
It is bad because it is not flexible,
what if you want to adapt your algorithm to another container ?
> 2. Packing your luggage ….
…. data structures
71. Objection:
It is bad because it is not flexible,
what if you want to adapt your algorithm to another container ?
Answer:
I m not going to use something else than a vector, because it is the best
choice for the mesh data structure. Why keeping a tuning knob on the
dash board if it is always on the same position ?
modern/generic != futuristic
> 2. Packing your luggage ….
…. data structures
72. Objection:
It is bad because it is not flexible,
what if you want to adapt your algorithm to another container ?
Answer:
I m not going to use something else than a vector, because it is the best
choice for the mesh data structure. Why keeping a tuning knob on the
dash board if it is always on the same position ? (think of the I-Phone)
The Nokia N95, a
modern/generic phone.
The I-phone,
a futuristic phone.
modern/generic != futuristic
> 2. Packing your luggage ….
…. data structures
73. modern/generic != futuristic
It is good because it has
everything that you need
The Nokia N95, a
modern/generic phone.
The I-phone,
a futuristic phone.
> 2. Packing your luggage ….
…. data structures
74. modern/generic != futuristic
It is good because it has
everything that you need
It is even better because it has
nothing else than what you need
The Nokia N95, a
modern/generic phone.
The I-phone,
a futuristic phone.
> 2. Packing your luggage ….
…. data structures
75. modern/generic != futuristic
It is good because it has
everything that you need
It is even better because it has
nothing else than what you need
Work is finished when you have
nothing to add and nothing to remove !
The Nokia N95, a
modern/generic phone.
The I-phone,
a futuristic phone.
> 2. Packing your luggage ….
…. data structures
76. Why keeping a tuning knob on the dash board if it is always
on the same position ? (think of the I-Phone)
A parameter that always has the same value is not a parameter and should be
removed from the API.
A template that is instanced only once should not be a template.
> 2. Packing your luggage ….
…. data structures
77. A parameter that always has the same value is not a parameter and should be
removed from the API.
A template that is instanced only once should not be a template.
Objection: but we loose genericity if we do that ???
Why keeping a tuning knob on the dash board if it is always
on the same position ? (think of the I-Phone)
> 2. Packing your luggage ….
…. data structures
78. A parameter that always has the same value is not a parameter and should be
removed from the API.
A template that is instanced only once should not be a template.
Objection: but we loose genericity if we do that ???
Answer to objection: but we gain a lot, it declutters the
code, makes it more legible, reduces compilation times,
makes C++ compilation error messages more legible.
Why keeping a tuning knob on the dash board if it is always
on the same position ? (think of the I-Phone)
> 2. Packing your luggage ….
…. data structures
79. Rule of thumb:
Make it a parameter not before you need it with at least two different values.
Make it a template not before you need at least two different instanciations.
*regarding compilation time, legibiity of error messages and run-time flex.
> 2. Packing your luggage ….
…. data structures
80. Rule of thumb:
Make it a parameter not before you need it with at least two different values.
Make it a template not before you need at least two different instanciations.
About templates, consider less annoying* alternatives, such as
(1) object oriented programming / virtual functions
(2) or simply a parameter and if() statements
*regarding compilation time, legibility of error messages and run-time flex.
> 2. Packing your luggage ….
…. data structures
82. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
83. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Pointset processing
84. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Transfer attributes
between meshes
(texture baking)
85. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Raytracing with
meshes
86. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Raytracing with
meshes
87. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
How do you compute line-triangle intersection ?
[Moller Trumbore]
Google search “stack overflow intersection between line and triangle in 3D”,
See part 3 of the first answer, it is super well explained, I’m 100% objective :-)
88. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Martin Carvaga
NVidia
109. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Shadertoy
Geogram
110. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Other topics on geometric search
AABB:
SAH (Surface Area Heuristic)
ZMAABB (Zero Memory) [Terdiman]
KdTrees
Pointsets, nearest neighbors queries
111. *regarding compilation time, legibility of error messages and run-time flex.
> 3. Finding your way….
…. Geometric search
Other topics on geometric search
AABB:
SAH (Surface Area Heuristic)
ZMAABB (Zero Memory) [Terdiman]
KdTrees
Pointsets, nearest neighbors queries
Take home message:
Continuous arrays
As simple as possible
Only store what‟s necessary:
- permute elements of mesh
- plus a couple of additional arrays
116. >4. Connecting with friends ….
… Voronoi and Delaunay
Classical algorithm:
Bowyer & Watson
Much material online:
- Hang Si
- Jonathan Shewchuk
- CGAL manuals
117. >4. Connecting with friends ….
… Voronoi and Delaunay
Constrained Delaunay triangulation
118. >4. Connecting with friends ….
… Voronoi and Delaunay
Easty-to-read reference:
S.W. Sloan,
A fast algorithm for
generating constrained
Delaunay triangulation,
1992
Implementation in Geogram:
CDT2d
Constrained Delaunay triangulation
119. Pointset X Simplicial complex S
>4. Connecting with friends ….
… Voronoi and Delaunay
120. Pointset X Simplicial complex S
either triangulated surface
or tetrahedralized solid
>4. Connecting with friends ….
… Voronoi and Delaunay
121. Pointset X Simplicial complex S
either triangulated surface
or tetrahedralized solid
Embedded in IRd
>4. Connecting with friends ….
… Voronoi and Delaunay
123. Voronoi cells as iterative convex clipping
xi
>4. Connecting with friends ….
… Voronoi and Delaunay
“Meshless Voronoi diagrams”
124. Voronoi cells as iterative convex clipping
Neighbors in increasing distance from xi
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
>4. Connecting with friends ….
… Voronoi and Delaunay
125. Voronoi cells as iterative convex clipping
Bisector of xi, x1
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
>4. Connecting with friends ….
… Voronoi and Delaunay
126. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
π+(i,1)
π-(i,1)
This side: The other side:
>4. Connecting with friends ….
… Voronoi and Delaunay
127. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
π+(i,1)
π-(i,1)
This side: The other side:
Remove π-(i,1)
>4. Connecting with friends ….
… Voronoi and Delaunay
128. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
Then remove π-(i,2)
>4. Connecting with friends ….
… Voronoi and Delaunay
129. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
… then remove π-(i,3)
>4. Connecting with friends ….
… Voronoi and Delaunay
130. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
… then remove π-(i,4)
>4. Connecting with friends ….
… Voronoi and Delaunay
131. Voronoi cells as iterative convex clipping
Half-space clipping
xi
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
… then remove π-(i,5)
>4. Connecting with friends ….
… Voronoi and Delaunay
132. Voronoi cells as iterative convex clipping
When should I stop ?
x1
x2
x3
x4
x5
x7
x8
x9
x10
x11
x6
>4. Connecting with friends ….
… Voronoi and Delaunay
133. Voronoi cells as iterative convex clipping
When should I stop ? Rk
x1
x2
x3
x4
x5
x7
x8
x9
x10
x11
x6
>4. Connecting with friends ….
… Voronoi and Delaunay
134. Voronoi cells as iterative convex clipping
When should I stop ?
x1
x2
x3
x4
x5
x7
x8
x9
x10
x11
x6
>4. Connecting with friends ….
… Voronoi and Delaunay
135. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
x1
x2
x3
x4
x5
x7
x8
x9
x10
x11
x6
>4. Connecting with friends ….
… Voronoi and Delaunay
136. Voronoi cells as iterative convex clipping
Observation: d(xi, xk+1) > 2Rk → ∩ π+(i,k) = Vor(xi)
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
137. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
138. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
Note: Rk decreases and d(xi, xk) increases
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
139. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
Note: Rk decreases and d(xi, xk) increases
Advantages:
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
140. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
Note: Rk decreases and d(xi, xk) increases
Advantages:
(1) Compute Vor(X) ∩ S directly (start with f and clip)
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
141. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
Note: Rk decreases and d(xi, xk) increases
Advantages:
(1) Compute Vor(X) ∩ S directly (start with f and clip)
(2) Replace Delaunay with ANN ! (no d! factor)
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
142. Voronoi cells as iterative convex clipping
When should I stop ? d(xi, xk) > 2 Rk
“Radius of security” is reached
Note: Rk decreases and d(xi, xk) increases
Advantages:
(1) Compute Vor(X) ∩ S directly (start with f and clip)
(2) Replace Delaunay with ANN ! (no d! factor)
(3) Parallelization is trivial (partition S and // in parts)
[L and Bonneel – Voronoi Parallel Linear Enumeration]
[Dey et.al – Localized co-cone]
>4. Connecting with friends ….
… Voronoi and Delaunay
146. xi
xj
Elementary operation: cut a polygon
(or polyhedron) with a bisector
Classify the vertices of the polygon
> 5. Into darkness …
… geometric predicates
147. xi
xj
Elementary operation: cut a polygon
(or polyhedron) with a bisector
Classify the vertices of the polygon
Sign( d(p,xj) – d(p,xi)) > 0
> 5. Into darkness …
… geometric predicates
148. xi
xj
Elementary operation: cut a polygon
(or polyhedron) with a bisector
Classify the vertices of the polygon
Sign( d(p,xj) – d(p,xi)) > 0
Sign( d(p,xj) – d(p,xi)) < 0
> 5. Into darkness …
… geometric predicates
149. xi
xj
Elementary operation: cut a polygon
(or polyhedron) with a bisector
Classify the vertices of the polygon
Compute the intersections
Sign( d(p,xj) – d(p,xi)) > 0
Sign( d(p,xj) – d(p,xi)) < 0
> 5. Into darkness …
… geometric predicates
150. xi
xj
Sign( d(p,xj) – d(p,xi)) > 0
Sign( d(p,xj) – d(p,xi)) < 0
Elementary operation: cut a polygon
(or polyhedron) with a bisector
Classify the vertices of the polygon
Compute the intersections - discard
> 5. Into darkness …
… geometric predicates
151. xi
xj
xk Now clipping with the bisector of (xi, xk)
> 5. Into darkness …
… geometric predicates
152. xi
xj
xk Now clipping with the bisector of (xi, xk)
We need to classify all the points, including
these ones !
> 5. Into darkness …
… geometric predicates
153. xi
xj
xk Now clipping with the bisector of (xi, xk)
We need to classify all the points, including
these ones !
(they are intersections between a
segment and a bisector)
> 5. Into darkness …
… geometric predicates
154. xi
xj
xk Now clipping with the bisector of (xi, xk)
We need to classify all the points, including
these ones !
(they are intersections between a
segment and a bisector)
This generates a new intersection
(between a facet and two bisector)
> 5. Into darkness …
… geometric predicates
161. Three configurations
1) Side1(xi,xj,q)
2) Side2(xi,xj,xk,p1,p2)
3) Side3(xi,xj,xk, xl,p1,p2,p3)
Implementations of exact predicates:
- J. Shewchuk‟s code
- CGAL (Pion, Meyer)
> 5. Into darkness …
… geometric predicates
162. Three configurations
1) Side1(xi,xj,q)
2) Side2(xi,xj,xk,p1,p2)
3) Side3(xi,xj,xk, xl,p1,p2,p3)
Implementations of exact predicates:
- J. Shewchuk‟s code
- CGAL (Pion, Meyer)
They do not have Side1(), Side2(), Side3() (“exotic predicates”)
> 5. Into darkness …
… geometric predicates
163. Three configurations
1) Side1(xi,xj,q)
2) Side2(xi,xj,xk,p1,p2)
3) Side3(xi,xj,xk, xl,p1,p2,p3)
How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
> 5. Into darkness …
… geometric predicates
164. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Wish list:
• Easy to use
(no “Guru” needed for each new predicate)
• Reasonably efficient
• Easy to compile/integrate
(multi_precision.h, multi_precision.cpp and that‟s all)
> 5. Into darkness …
… geometric predicates
165. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #1: (dense) multi-precision (GMP)
a0
a1
a2
a3
x 20
x 21*32
x 22*32
x 23*32
…
Each number is an array of (32 bits) integers:
Implement +,-,* (reasonably easy)
Sign: look at the leading non-zero component
> 5. Into darkness …
… geometric predicates
166. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #1: (dense) multi-precision (GMP)
a “limitation”:
c = a10 * 210*32 + b0
> 5. Into darkness …
… geometric predicates
167. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #1: (dense) multi-precision (GMP)
a “limitation”:
b0
0
0
a10
x 20
x 210*32
c = a10 * 210*32 + b0
…
> 5. Into darkness …
… geometric predicates
168. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #2: (sparse) multi-precision
b0 | 0
a10 | 10
c = a10 * 210*32 + b0
Store the exponents of the components
> 5. Into darkness …
… geometric predicates
169. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #2: (sparse) multi-precision
b0 | 0
a10 | 10
c = a10 * 210*32 + b0
Exp. Exp.
> 5. Into darkness …
… geometric predicates
170. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #2: (sparse) multi-precision
b0 | 0
a10 | 10
c = a10 * 210*32 + b0
Exp. Exp.
mantissa mantissa
> 5. Into darkness …
… geometric predicates
171. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #2: (sparse) multi-precision
b0 | 0
a10 | 10
c = a10 * 210*32 + b0
Exp. Exp.
mantissa mantissa
These are floating point numbers !!!
> 5. Into darkness …
… geometric predicates
172. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x3 x2 x1
…
Each number is represented by the sum of an array of „components‟
These are floating point numbers !!!
> 5. Into darkness …
… geometric predicates
173. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x3 x2 x1
…
Each number is represented by the sum of an array of „components‟
They are sorted in decreasing exponents
These are floating point numbers !!!
> 5. Into darkness …
… geometric predicates
174. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x3 x2 x1
…
Each number is represented by the sum of an array of „components‟
They are sorted in decreasing exponents
They are „non-overlapping‟
These are floating point numbers !!!
> 5. Into darkness …
… geometric predicates
175. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x3 x2 x1
…
Each number is represented by the sum of an array of „components‟
They are sorted in decreasing exponents
They are „non-overlapping‟
The sign is determined by the first component (highest exponent)
These are floating point numbers !!!
> 5. Into darkness …
… geometric predicates
176. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x2 x1
Two_sum(double a, double b)
> 5. Into darkness …
… geometric predicates
177. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x2 x1
Two_sum(double a, double b)
+
Length:
l+m
Length l Length m
> 5. Into darkness …
… geometric predicates
178. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
x2 x1
Two_sum(double a, double b)
+
*
Length:
l+m
Length:
2*l
A double
Length l
> 5. Into darkness …
… geometric predicates
179. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
* …
Length: 2*l*m
Expansion * Expansion product implemented by a recursive function
(“distillation”)
Length l Length m
> 5. Into darkness …
… geometric predicates
180. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
* …
Expansion * Expansion product implemented by a recursive function
(“distillation”)
Performance ? 10 to 40 times slower than standard doubles
Length: 2*l*m
Length l Length m
> 5. Into darkness …
… geometric predicates
181. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
* …
Expansion * Expansion product implemented by a recursive function
(“distillation”)
Performance ? 10 to 40 times slower than standard doubles
Use arithmetic filters
Adaptive precision [Shewchuk] ? Too complicated to get right
Length: 2*l*m
Length l Length m
> 5. Into darkness …
… geometric predicates
182. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
Idea #3: expansions (Shewchuk)
* …
Expansion * Expansion product implemented by a recursive function
(“distillation”)
Performance ? 10 to 40 times slower than standard doubles
Use arithmetic filters
Adaptive precision [Shewchuk] ? Too complicated to get right
Quasi-static filters [Meyer and Pion] – FPG generator (easy to use)
Length: 2*l*m
Length l Length m
> 5. Into darkness …
… geometric predicates
183. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
PCK (Predicate Construction Kit)
multi_precision.h / multi_precision.cpp
A “low-level” expansion class (allocates expansions on stack)
A “high-level” C++ number type (+,-,*,Sign overloads)
a script that generates the filter with FPG [Meyer and Pion] and the
exact precision version with expansions
> 5. Into darkness …
… geometric predicates
184. How to implement Side1(), Side2(), Side3() ?
We need an exact “number type” with +,-,*,Sign()
PCK (Predicate Construction Kit)
multi_precision.h / multi_precision.cpp
A “low-level” expansion class (allocates expansions on stack)
A “high-level” C++ number type (+,-,*,Sign overloads)
a script that generates the filter with FPG [Meyer and Pion] and the
exact precision version with expansions
So we are done ?
> 5. Into darkness …
… geometric predicates
185. How to implement Side1(), Side2(), Side3() ?
xi
xj
Not yet !!
> 5. Into darkness …
… geometric predicates
186. How to implement Side1(), Side2(), Side3() ?
xi
xj
Not yet !!
> 5. Into darkness …
… geometric predicates
204. xi
xj
πw(i,j) = {p | d2(p,xi) - wi = d2(p,xj) - wj}
[Voronoi]
[Edelsbrunner et.al]
[Devillers et.al]
> 5. Into darkness …
… geometric predicates
205. xi
xj
πw(i,j) = {p | d2(p,xi) - wi = d2(p,xj) - wj}
[Voronoi]
[Edelsbrunner et.al]
[Devillers et.al]
The Voronoi diagram is replaced with a power diagram
> 5. Into darkness …
… geometric predicates
206. xi
xj
πw(i,j) = {p | d2(p,xi) - wi = d2(p,xj) - wj}
[Voronoi]
[Edelsbrunner et.al]
[Devillers et.al]
The Voronoi diagram is replaced with a power diagram
Symbolic perturbation – Simulation of Simplicity:
Define the weight as a function of ε: wi = εi
> 5. Into darkness …
… geometric predicates
207. xi
xj
πw(i,j) = {p | d2(p,xi) - wi = d2(p,xj) - wj}
[Voronoi]
[Edelsbrunner et.al]
[Devillers et.al]
The Voronoi diagram is replaced with a power diagram
Symbolic perturbation – Simulation of Simplicity:
Define the weight as a function of ε: wi = εi
The combinatorics is determined by the limit ε → 0
> 5. Into darkness …
… geometric predicates
208. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
> 5. Into darkness …
… geometric predicates
209. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
Solve for q in:
q Є πw(i,k1)
…
q Є πw(i,kd)
q Є [p1,p2,p3…pd]
{
> 5. Into darkness …
… geometric predicates
210. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
q = (1/d) Q
Keep numerator and denom.
separate (remember, we are
not allowed to divide)
Solve for q in:
q Є πw(i,k1)
…
q Є πw(i,kd)
q Є [p1,p2,p3…pd]
{
> 5. Into darkness …
… geometric predicates
211. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
q = (1/d) Q
Keep numerator and denom.
separate (remember, we are
not allowed to divide)
Inject q=(1/d) Q in side1() and mutliply by d to remove the division
Solve for q in:
q Є πw(i,k1)
…
q Є πw(i,kd)
q Є [p1,p2,p3…pd]
{
> 5. Into darkness …
… geometric predicates
212. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
q = (1/d) Q
Keep numerator and denom.
separate (remember, we are
not allowed to divide)
Inject q=(1/d) Q in side1() and mutliply by d to remove the division
Order the terms in wi = εi
Solve for q in:
q Є πw(i,k1)
…
q Є πw(i,kd)
q Є [p1,p2,p3…pd]
{
> 5. Into darkness …
… geometric predicates
213. How to write side1(), side2(), side3(), side4() ?
d2(q,pj)-wj – d2(q,pi) + wi where:
q = πw(i,k1) ∩ … πw(i,kd) ∩ [p1,p2,p3…pd]
q = (1/d) Q
Keep numerator and denom.
separate (remember, we are
not allowed to divide)
Inject q=(1/d) Q in side1() and mutliply by d to remove the division
Order the terms in wi = εi the constant one is non-perturbed predicate
if zero, the first non-zero one determines the sign
Solve for q in:
q Є πw(i,k1)
…
q Є πw(i,kd)
q Є [p1,p2,p3…pd]
{
> 5. Into darkness …
… geometric predicates
214. #include "kernel.pckh"
Sign predicate(side1)(
point(p0), point(p1), point(q0) DIM
) {
scalar r = sq_dist(p0,p1) ;
r -= 2*dot_at(p1,q0,p0) ;
generic_predicate_result(sign(r)) ;
begin_sos2(p0,p1)
sos(p0,POSITIVE)
sos(p1,NEGATIVE)
end_sos
}
Source PCK
> 5. Into darkness …
… geometric predicates
215. #include "kernel.pckh"
Sign predicate(side1)(
point(p0), point(p1), point(q0) DIM
) {
scalar r = sq_dist(p0,p1) ;
r -= 2*dot_at(p1,q0,p0) ;
generic_predicate_result(sign(r)) ;
begin_sos2(p0,p1)
sos(p0,POSITIVE)
sos(p1,NEGATIVE)
end_sos
}
Source PCK
(p1-p0).(q0-p0)
> 5. Into darkness …
… geometric predicates
237. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
238. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Physics
Math
Computer
Science
239. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Physics
Math
Computer
Science
Got the feeling that
there are intersting
things to discover
exactly here !
240. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Physics
Math
Computer
Science
A journey in Mathland
241. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Math
A journey in Mathland
Optimal
transport
A numerical algorithm for
Semi-discrete OT in 3D,
ESAIM Math Modeling
and Analysis, L, 2015
Centroidal Power Diagrams,
ACM TOG/SIGGRAPH Asia,
Xin, L, Chen, Chu, Yue, Wang
2016
Notions of OT theory and how
to implement them on a
Computer,
Computer & Graphics,
L & Schwindt, 2018
BIRS Banff, BIRS Oaxaca,
Institut Fourier, Bonn
242. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Math
A journey in Mathland
Optimal
transport Recorded lecture
& slides on the web
Links from my webpage
brunolevy.github.io
SGP2018 Graduate Course
243. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Math
The trip continues in Physland…
Optimal
transport
Physics
Computational
fluid
dynamics
C.S.
244. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Free-surface fluid simulation, J. of computational Physics, B, 2022
245. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Math
The trip continues in Physland…
Optimal
transport
Physics
Computational
fluid
dynamics
C.S.
Cosmology
246. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Monthly Notices of the Royal Astron Soc., L, Mohayaee, S.von Hausegger 2021
Physical Review Letters, von Hausegger, L, Mohayaee, 2022
Physical Review Letters, Nikhaktar, Sheth, L, Mohayaee, 2022
Featured in Physics Magazine
A mathematical time machine to explore the origins of the Universe
247. *regarding compilation time, legibility of error messages and run-time flex.
>6. Planning your next trip ….
… GP in other sciences
Math
Love Physland, I settled down there !
Optimal
transport
Physics
Computational
fluid
dynamics
C.S.
Cosmology
251. The “product”: geogram (on github)
Is it good ? Yes and no
23 years of code, 40 papers, 2 ERCs
+ functionalities, efficiency, small footprint
+ few dependencies
+ high portability (Linux/Mac/Win/Android/web)
+ heavily tested
- there is technical debt
- arrays/pointers-based,
API may feel a bit weird and low-level
253. What GP can do for other sciences
- Dare computing what others would not dream of.
- Mix of math. and algorithmics.
- C++ ninjas, high tech (GPUs…).
- Irregular geometric data structures.