CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Geometric Modeling Assignment 3: Discrete Differential Quantities
Acknowledgements: Julian Panetta, Olga Diamanti
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Assignment 3 (Optional)• Topic: Discrete Differential Quantities with libigl
• Vertex Normals, Curvature, Smoothing (Tutorials 201-205)
per-face
per-vertex, uniform
per-vertex, quadratic fit
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Vertex Normals
uniform average area-weighted average mean-curvature based
quadratic fitting on k-nearest neighborsPCA on k-nearest neighbors
libigl tutorial #201, igl::principal_curvature
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Curvature
min max
mean gauss
libigl tutorials #202, #203
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
• Mean Curvature
• Gaussian Curvature
• Min Curvature • Max Curvature
H(vi) = 0.5kLc(vi)k
Curvature
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
1 = H +pH2 �G
1 = H �pH2 �G
G = 12
2H = 1 + 2
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Data Smoothing: Grid Case• Image/2D data smoothing:
Filter out noise/rapid oscillations
• Solve the heat equation over some time period:
• Intuition: move toward the average of neighboring values
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
@f
@t= ��f = �
✓@2f
@x2+
@2f
@y2
◆
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Data Smoothing: Grid Case
• Approach: discretize laplacian with finite differences
• Now we have an ordinary differential equation (ODE)
• Integrate (time-step) the ODE, e.g., with forward/backwards Euler
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
Diffusion Flow
10
∂f
∂t= λ∆f
diffusion constant
Laplace operator
@f
@t= ��f = �
✓@2f
@x2+
@2f
@y2
◆
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Data Smoothing: Surface Case• Laplace-Beltrami operator lets us smooth functions on surfaces, S
• E.g., with forward Euler (explicit smoothing) on a triangle mesh, M:
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
@f
@t= ��Sf
discrete Laplacian weightsvertices adjacent vi
f t+dt(vi) = f t(vi) + � dt �Mf t(vi)
= f t(vi) + � dt
0
@X
vj2N(vi)[{vi}
wijft(vj)
1
A
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Mesh Smoothing• We can view the vertex positions as a (vector-valued) function to smooth!
• Here, first-order explicit time stepping looks like:
• Note: Laplacian weights generally change when mesh changes!
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
C0 C1 C2
@f
@t= ���f
f(vi) =
2
4xi
yizi
3
5
f t+dt(vi) = f t(vi) + � dt �Mf t(vi) =)vnewi = vi + � dt (�Mv)i
= vi + � dt
0
@X
vj2N(vi)[{vi}
wijvj
1
A
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Explicit Smoothing• In matrix form:
• Intuition: vertices moving toward neighbor average.
Diffusion Flow on Meshes
• Continuous
• Discretization
21
0 Iterations 10 Iterations 100 Iterations
@p
@t= ��p
pi pi + �t��pi
Diffusion Flow on Meshes
• Continuous
• Discretization
21
0 Iterations 10 Iterations 100 Iterations
@p
@t= ��p
pi pi + �t��pi
Diffusion Flow on Meshes
• Continuous
• Discretization
21
0 Iterations 10 Iterations 100 Iterations
@p
@t= ��p
pi pi + �t��pi
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
(I � �dtL)vn+1 = vn
vn+1 = v
n + �dtLvn+1
vn+1 � v
n = �dtLvn
vn+1 = (I + �dtL)vn
@v
@t= �L(v)
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
(I � �dtL)vn+1 = vn
vn+1 = v
n + �dtLvn+1
vn+1 � v
n = �dtLvn
vn+1 = (I + �dtL)vn
@v
@t= �L(v)
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
(I � �dtL)vn+1 = vn
vn+1 = v
n + �dtLvn+1
vn+1 � v
n = �dtLvn
vn+1 = (I + �dtL)vn
@v
@t= �L(v)
@f
@t= ���f
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Implicit Smoothing• “Backward Euler” is more stable
• Take larger time steps without mesh “blowing up” (becoming jagged)
original explicit, 1000 iterations,λ = 0.01
implicit, 1 iteration, λ = 20
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
(I � �dtL)vn+1 = vn
vn+1 = v
n + �dtLvn+1
vn+1 � v
n = �dtLvn
vn+1 = (I + �dtL)vn
@v
@t= �L(v)
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
(I � �dtL)vn+1 = vn
vn+1 = v
n + �dtLvn+1
vn+1 � v
n = �dtLvn
vn+1 = (I + �dtL)vn
@v
@t= �L(v)
@f
@t= ���f
libigl tutorial #205
Laplacian at next (unknown) step! Must solve a linear system:
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
2D Rectangular Grid Laplacian
Measures difference from neighbor’s average (if we divide by 4/h^2):
11 -4 1
1
RANDOM EQUATIONS FOR SLIDES
OLGA DIAMANTI
1. Laplace-operator
f : R3 ! R
rf =
2
66664
@f@x
@f@y
@f@z
3
77775
�f : R3 ! R
�f = divrf = r ·rf
rf =h
@f@x
@f@y
@f@z
i
2
66664
@f@x
@f@y
@f@z
3
77775=
@2f
@x2+
@2f
@y2+
@2f
@z2
f : S ! R
�f = divSrSf
�f(xi) =X
j2N(i)
f(xj)� 4f(xi)
�f(v) =X
vj2N(v)
f(vj)� f(v)
=X
vj2N(v)
f(vj)� kf(v), k = |N(v)|
1
RANDOM EQUATIONS FOR SLIDES
OLGA DIAMANTI
1. Laplace-operator
f : R3 ! R
rf =
2
66664
@f@x
@f@y
@f@z
3
77775
�f : R3 ! R
�f = divrf = r ·rf
rf =h
@f@x
@f@y
@f@z
i
2
66664
@f@x
@f@y
@f@z
3
77775=
@2f
@x2+
@2f
@y2+
@2f
@z2
f : S ! R
�f = divSrSf
�f(xi) =X
j2N(i)
f(xj)� 4f(xi)
�f(v) =X
vj2N(v)
f(vj)� f(v)
=X
vj2N(v)
f(vj)� kf(v), k = |N(v)|
1
Weights can be represented by a “stencil:”
h
h �hf(xi) :=1
h2
2
4
0
@X
xj2N(xi)
f(xj)
1
A� 4f(xi)
3
5
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
2D Rectangular Grid Laplacian1
1 -4 11
RANDOM EQUATIONS FOR SLIDES
OLGA DIAMANTI
1. Laplace-operator
f : R3 ! R
rf =
2
66664
@f@x
@f@y
@f@z
3
77775
�f : R3 ! R
�f = divrf = r ·rf
rf =h
@f@x
@f@y
@f@z
i
2
66664
@f@x
@f@y
@f@z
3
77775=
@2f
@x2+
@2f
@y2+
@2f
@z2
f : S ! R
�f = divSrSf
�f(xi) =X
j2N(i)
f(xj)� 4f(xi)
�f(v) =X
vj2N(v)
f(vj)� f(v)
=X
vj2N(v)
f(vj)� kf(v), k = |N(v)|
1
RANDOM EQUATIONS FOR SLIDES
OLGA DIAMANTI
1. Laplace-operator
f : R3 ! R
rf =
2
66664
@f@x
@f@y
@f@z
3
77775
�f : R3 ! R
�f = divrf = r ·rf
rf =h
@f@x
@f@y
@f@z
i
2
66664
@f@x
@f@y
@f@z
3
77775=
@2f
@x2+
@2f
@y2+
@2f
@z2
f : S ! R
�f = divSrSf
�f(xi) =X
j2N(i)
f(xj)� 4f(xi)
�f(v) =X
vj2N(v)
f(vj)� f(v)
=X
vj2N(v)
f(vj)� kf(v), k = |N(v)|
1
Derivation:
Compute second derivatives by finite-differencing the forward difference approximation to first derivative:
Sum second partial derivative approximations for each dimension:
@2f
@x2(x, y) ⇡ 1
h
✓f(x+ h, y)� f(x, y)
h� f(x, y)� f(x� h, y)
h
◆
=f(x+ h, y) + f(x� h, y)� 2f(x, y)
h2=)
�f(x, y) =@2f
@x2(x, y) +
@2f
@y2(x, y)
⇡ f(x+ h, y) + f(x� h, y) + f(x, y + h) + f(x, y � h)� 4f(x, y)
h2
�hf(xi) :=1
h2
2
4
0
@X
xj2N(xi)
f(xj)
1
A� 4f(xi)
3
5
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Irregular Grid (Mesh) LaplacianDiscrete Laplace-Beltrami
k First approach: Assume uniformity as in the grid case
CGL slideset 8
0
( ) ( ) = limh
f f x h f xx ho
w � �w
1( ( ) ( ),.., ( ) ( ))kf f v f v f v f v� � �
• First approach: “umbrella operator” • assume all edges are unit length • depends only on connectivity, not vertex locations
• Notice, when edge length h = 1 the 2D grid laplacian is:
• This version easily generalizes to an arbitrary mesh, M:
�uniformM f(v) =
X
vj2N(v)
✓f(vj)� f(v)
◆
=
0
@X
vj2N(v)
f(vj)
1
A� |N(v)|f(v)
�hf(xi) =1
h2
2
4
0
@X
xj2N(xi)
f(xj)
1
A� 4f(xi)
3
5 =X
xj2N(xi)
✓f(xj)� f(xi)
◆
#neighbors
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
The “Umbrella” (Uniform) Laplacian
In Matrix Form:
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
a(x, y, z) = x
b(x, y, z) = y
b(x, y, z) = z
f(x, y, z) =
2
4a(x, y, z)b(x, y, z)x(x, y, z)
3
5
vsmoothed = vi + ��Sf(vi)
= vi + �
X
vj2N(vi)
wivj
C0 C1 C2
Y = LFRANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
�uniformM f(v) =
0
@X
vj2N(v)
f(vj)
1
A� |N(v)|f(v)
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
The Cotangent Laplacian
•Accounts for edges’ differing lengths. •Converges to the continuous Laplace-Beltrami operatorwith mesh refinement
•Derivation in next recitation lecture.
Discrete Laplace-Beltrami
k Second Approach: Cotangent Formula
CGL slideset 10
Discrete Laplace-Beltrami
k Second Approach: Cotangent Formula
CGL slideset 10
Discrete Laplace-Beltrami
k Second Approach: Cotangent Formula
CGL slideset 10
�cotanM f(v) =
1
2A(v)
X
vi2N(v)
(cot(↵i) + cot(�i))
✓f(vi)� f(v)
◆
�S
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
The Cotangent Laplacian
In Matrix Form:
2 OLGA DIAMANTI
�Sf(v) =1
2A(v)
X
vj2N(v)
(cot↵j + cot�j) (f(vj)� f(v))
�Sp = �2Hn
H(vi) = 0.5kLc(vik
G(vi) =
2⇡ �Pj✓j
A(vi)
1(vi) = H(vi) +pH2(vi)�G(vi)
2(vi) = H(vi)�pH2(vi)�G(vi)
a(x, y, z) = x
b(x, y, z) = y
b(x, y, z) = z
f(x, y, z) =
2
4a(x, y, z)b(x, y, z)x(x, y, z)
3
5
vsmoothed = vi + ��Sf(vi)
= vi + �
X
vj2N(vi)
wivj
C0 C1 C2
Y = LFRANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
�|N(vi)| i = j
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
RANDOM EQUATIONS FOR SLIDES 3
Y =
2
66664
�f(v1)�f(v2)�f(v3)
· · ·�f(vN )
3
77775
L =
2
6664
w11 w12 · · · w1N
w21 w22 · · · w2N...
... · · ·...
wN1 wN2 · · · wNN
3
7775= {wij}
wij =
8<
:
0 i 6= j, @ edge (i, j)1 i 6= j, 9 edge (i, j)�|N(vi)| i = j
wij =
8>><
>>:
0 i 6= j, @ edge (i, j)cot↵j+cot�j
2A(vi)i 6= j, 9 edge (i, j)
�P
vk2N(vi)wik i = j
F =
2
66664
f(v1)f(v2)f(v3)· · ·
f(vN )
3
77775
@f
@t= ���f
�cotanM f(v) =
1
2A(v)
X
vi2N(v)
(cot(↵i) + cot(�i))
✓f(vi)� f(v)
◆
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Eigen Sparse Matrix• Full-sized Laplacian can be huge for large meshes
• but most elements are zero!
• Instead, only store non-zero elements: Sparse Matrix
#include <Eigen/Sparse>
Eigen::SparseMatrix<double> Laplacian;
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Eigen Sparse Matrix• How to construct a sparse matrix in Eigen://declare size of matrix L = SparseMatrix<double> (V.rows(), V.rows());
//declare list of non-zero elements (row, column, value) std::vector<Eigen::Triplet<double> > tripletList;
//insert element to the list //if multiple triplets exist with the same row and column, values will be *added* tripletList.push_back(Eigen::Triplet<double>(source,dest,C(i,e)));
//construct matrix from the list L.setFromTriplets(tripletList.begin(), tripletList.end());
see igl::cotmatrix (V,F)
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
How to build cotangent matrix
• Iterating over vertices is slow
• Instead, iterate over faces and add cot terms to the vertices incident each face edge
for i = 1:number_of_faces for j = 1:face_valence source_vertex = faces(i,j); destination_vertex = faces(i,(j+1) % face_valence); weight = ....; //laplacian weight for edge (source_vertex, destination_vertex)(cotan or uniform) Laplacian(source_vertex, destination_vertex) += weight; Laplacian(destination_vertex, source_vertex) += weight; Laplacian(destination_vertex, destination_vertex) -= weight; Laplacian(source_vertex, source_vertex) -= weight;
end end
Discrete Laplace-Beltrami
k Second Approach: Cotangent Formula
CGL slideset 10
�cotanM f(v) =
1
2A(v)
X
vi2N(v)
(cot(↵i) + cot(�i))
✓f(vi)� f(v)
◆
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Averaged or Summed?• We’ll see next time that the cotan laplacian we introduced:computes the average Laplacian over some area “A” around v (hence the division by A)
• This gives an asymmetric matrix. But if we instead compute the “summed” laplacian (i.e., don’t divide by A), we end up with a symmetric matrix.
• This “summed,” symmetric Laplacian is more standard in the finite element community, and is related to our Laplacian by a “lumped (diagonal) mass matrix” holding the areas:
M =
2
6664
A(0) 0 · · · 00 A(1) · · · 0...
... · · ·...
0 0 · · · A(N)
3
7775
lumped mass matrix (averaging region areas)
�cotanM f(v) =
1
2A(v)
X
vi2N(v)
(cot(↵i) + cot(�i))
✓f(vi)� f(v)
◆
Laveraged = M�1Lsummed
[Lsummed]ij =
8>>><
>>>:
12
✓cot(↵ij) + cot(�ij)
◆if j 2 N(i)
�P
j2N(i)[Lsummed]ij if i = j
0 otherwise
(Laveraged corresponds to formula above)
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Averaged or Summed?• Suppose we have a linear system: i.e. using the asymmetric cotangent Laplacian we introduced earlier.
• Right hand side vector “b”represents a scalar field, storing the desired Laplacian value (not the summed value!) at each vertex.
• Solving symmetric sparse linear systems matrices is much more efficient, so we prefer to solve with the summed quantities:
Laveragedx = b
MLaveragedx = Lsummedx = Mb
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
How to compute A(v)• Barycentric area
• Connect edge midpoints and triangle barycenters
• Each of the incident triangles contributes 1/3 of its area to all its vertices, regardless of the placement
+ Simple to compute + Always positive weights - Heavily connectivity-dependent - Changes if edges are flipped
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
How to compute A(v)• Voronoi area
• Connect edge midpoints and triangle circumcenters
• The 3 resulting quadrilaterals are not equareal
• Sum contributions from incident triangles
+ Only depends on vertex positioning - More complicated computations
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
How to compute A(v)• Voronoi area
• Connect edge midpoints and triangle circumcenters
• The 3 resulting quadrilaterals are not equiareal
• Sum contributions from incident triangles
• For obtuse triangles, circumcenter is outside the triangle -> negative areas!
+ Only depends on vertex positioning - More complicated computation - May introduce negative weights (obtuse triangles)
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
How to compute A(v)• Voronoi area - compromise
• Connect edge midpoints with:
• triangle circumcenters , for non-obtuse triangles
• midpoint of opposite edge, for obtuse ones
• Sum contributions from incident triangles
+ Only depends on vertex positioning - More complicated computations
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Linear Systems with Eigen
• Cholesky factorization works only for symmetric, positive definite A! • Other solvers available, e.g. SparseLU:
• http://eigen.tuxfamily.org/dox/TutorialSparse.html
#include <Eigen/SparseCholesky> // ... SparseMatrix<double> A; // fill A VectorXd b, x; // fill b // solve Ax = b SimplicialLDLt<SparseMatrix<double> > solver; solver.compute(A); if(solver.info()!=Success) return; // decomposition failed x = solver.solve(b); if(solver.info()!=Success) return; // solving failed // solve for another right hand side: x1 = solver.solve(b1);
CSCI-GA.3033-018 - Geometric Modeling - Daniele Panozzo
Questions?