MESH ANALYSIS Lecture 4 (Discrete differential geometry) SURFACE APPROXIMATION • Polygonal meshes are most often intended as approximations of smooth surfaces • Since meshes have straight-line edges and flat faces, they are just C0 at their vertices and across edges • Differential properties of the surface are estimated either by fitting a smooth surface, or by an averaging process (discrete integration) 2 SURFACE APPROXIMATION • Surface fitting: compute a differential property at point p analytically, by fitting a smooth surface to a local neighborhood N(p) • Discrete integration: compute a differential property at point p as spatial average of a local neighborhood N(p) • For a mesh vertex vi, the neighborhood is usually its k-ring Nk(vi) for some given value of k • Rule of thumb: the larger the neighborhood, the more smoothing is introduced • more stable to noise • small details are lost 3 DISCRETE INTEGRATION • Vertex neighborhoods that partition the mesh into disjoint regions are often preferred: • barycentric cells v5 v4 • Voronoi cells • mixed Voronoi cells v6 v A(v) v1 4 Figure 5.1: The Laplace-Beltrami v3 v2 Sf (v) of a vertex v ⌅ V SURFACE NORMAL • Surface normal of a triangle t = (vi,vj,vk) is the normal of the plane containing t , i.e.: ! ! vi ) ⇥ (vk vi ) ⇥ (vk (vj n(t) = ||(vj vi ) vi )|| • Surface normal at a vertex v is computed as a weighted average of normals of its incident faces: ! ! n(v) = || P t2N1 (v) ↵t n(t) t2N1 (v) ↵t n(t)|| P where αt is the area of the averaging region related to t 5 AREA AND VOLUME • Total area of a mesh: X v1 v2 Af f 2M ! 1 • For a triangle mesh: Af = |(v1 2 v0 v0 ) ⇥ (v2 v0 )| ! • For the volume we use divergence theorem: ZZZ ⌦ · F(u)dV = 6 ZZ @⌦ F(u) · n(u)dA AREA AND VOLUME 1 • Set F(x) = x then we have divF(x) = 1 3 • Therefore ! VM = ! • For ZZZ the volume inside a mesh M is 1dV = ⌦M ZZZ 1 · ( u)dV = 3 ⌦M a polygonal mesh: VM ! where xf is any point inside face f 7 ZZ M 1 u · n(u)dA 3 1 X = x f · n f Af 3 f 2M CURVATURE VIA SURFACE FITTING The radius r of the neighborhood of each point p is used as a scale parameter 1. gather all faces in a local neighborhood of radius r 2. let n be the surface normal at p and ni be the surface normal at gathered vertex vi 3. discard all vertices vi such that ni ⋅ n < 0 8 CURVATURE VIA SURFACE FITTING 3. set a local frame (u,v,n) where u and v are any two orthogonal unit vectors lying on the tangent plane at p, and such that the frame is right-handed 4. express all vertices vi in such a local frame with origin at p 5. fit to these points a polynomial of degree two through p (least squares fitting): f (u, v) = au2 + bv 2 + cuv + du + ev 9 CURVATURE VIA SURFACE FITTING • Curvatures at p are computed analytically via first and second fundamental forms of f at the origin • Since f is a polynomial, coefficients E, F, G, L, M, N of the fundamental forms can be computed easily in closed form (they depend just on first and second derivatives of f ) • The shape operator is obtained with respect to frame (u,v,n) • SVD decomposition of the shape operator yields principal curvatures and principal curvature directions 10 CURVATURE VIA SURFACE FITTING • Curvatures extracted at different scales 11 CURVATURE VIA DISCRETE INTEGRATION • Normal curvature at vi along edge (vi,vj) can be estimated by fitting an osculating circle through vi and vj tangent to the plane defined by normal ni : ni (vi vj ) · ni ij = 2 ||vi vj ||2 12 vi 1 ij vj CURVATURE VIA DISCRETE INTEGRATION • Once κij has been computed for all vj‘s neighbors of vi, the second fundamental form can be estimated by least squares fitting of equations ! ! ij = tTij L M M N tij where tij denotes the unary projection on the tangent plane at vi of vector vj-vi, expressed in any orthogonal coordinate system (u,v,w) with origin at vi and w axis along ni 13 CURVATURE VIA DISCRETE INTEGRATION • A more accurate estimation of the curvature tensor at v can be computed by averaging curvature tensors defined along edges of a neighborhood N(v) • For a single edge e curvature is considered zero along e, and maximum according to the dihedral edge β(e) formed by the two incident faces across e X 1 C(v) = |N (v)| e2N (v) 14 ||e \ N (v)|| T (e) ee 2 ||e|| FUNCTIONS DEFINED ON SURFACE • Consider a (smooth) surface S and a smooth (C2) scalar field ! f :S !R • The concepts of partial derivatives, gradient, Laplacian, etc. can be generalized from traditional calculus of bivariate functions ! f :R⇥R !R to functions defined on S 15 GRADIENT • Let ƒ(u,v) be a bivariate smooth (C2) scalar field • The gradient of f is defined as: rf = • The ✓ fu fv ◆ gradient ∇ƒ(p) of a function ƒ at a point p is a vector on the plane pointing to the direction of maximal ascent of ƒ and having a size proportional to the rate of ascent 16 BARYCENTRIC COORDINATES • Each point p inside a triangle t can be written as a convex combination of the vertices of t p = Bi (p)vi + Bj (p)vj + Bk (p)vk ! • Each function Bi(p) is linear with value 1 at vi and 0 along edge vjvk 1 Bj(p) Bi(p) vk vi Bk(p) vk vi 1 vk vi 1 vj vj 17 vj GRADIENT ESTIMATION Let a function f be defined point-wise at the vertices of triangle mesh M fi = f (vi) and extended to all points of M by linear interpolation over each triangle ! f (p) = fi Bi (p) + fj Bj (p) + fk Bk (p) where p is a point of triangle t = (vivjvk) and Bi(p), Bj(p), Bk(p) are its barycentric coordinates in t 18 GRADIENT ESTIMATION • The gradient of f is defined as ! rf (p) = fi rBi (p) + fj rBj (p) + fk rBk (p) • Barycentric coordinates satisfy partition of unity: Bi (p) + Bj (p) + Bk (p) = 1 ! • Therefore rf (p) = (fj fi )rBj (p) + (fk 19 fi )rBk (p) GRADIENT ESTIMATION • Each function Bi(p) is linear and has value 1 at vi and 0 along edge vjvk 1 • Therefore ∇Bi(p) is constant over t, it is orthogonal to vjvk and directed towards vi Bi(p) vi vj )? vj rBi (p) = where At is the area of t 2At (vi vk )? (vj vi )? • Finally: rf (p) = (fj fi ) + (fk fi ) 2At 2At (vk 20 vk LAPLACE OPERATOR • Let ƒ(u,v) be a bivariate smooth (C2) scalar field • The f : ! Laplace operator is defined as the divergence of the gradient of f = r2 f = r · rf = fuu + fvv • The Laplacian Δƒ(p) of a function ƒ at a point p is the rate at which the average value of ƒ over disks centered at p, deviates from ƒ(p) as the radius of the disk grows •A function is said to be harmonic if its Laplacian is null at all points 21 LAPLACE-BELTRAMI OPERATOR • The Laplace operator can be generalized for a function f defined on a surface S: f :S !R ! Sf = divS rS f where the gradient and divergence need suitable definitions that take into account the metrics on S (through the first fundamental form) • If we apply the Laplace-Beltrami operator (element-wise) to the coordinate function X of S, we obtain: ! SX = 2Hn where H denotes the mean curvature and n denotes the surface normal 22 ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Uniform Laplacian: • directly measure the difference between function at a vertex with respect to the average of its neighbors 1 f (vi ) = |N1 (vi )| ! ! • it X (fj vj 2N1 (vi ) does not take into account mesh geometry • not accurate for non-uniform meshing 23 fi ) • Cotangent formula ESTIMATION OF LAPLACEBELTRAMI2OPERATOR ! ∆S f (v) := • Cotangent formula: A(v) • we (cot αi + cot βi ) vi ∈N1 (v) integrate the value of the Laplacian over the averaging region A(v) about a vertex v v ! 1 f (v) = A(v) ZZ v A(v) α f (u)dA A(v) vi vi 24 vi ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent • makes ! ! formula: use of the divergence theorem: ZZ A r · F(u)dA = I @A F(u) · n(u)ds where n(u) is the outward pointing unit normal at each point u of the boundary of region A 25 ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent Z! formula: f (u)dA = A(v) ! • we Z Z divrf (u)dA = A(v) Z @A(v) rf (u) · n(u)ds split the integral separately for each triangle of A(v) : @A(v) rf (u) · n(u)ds = X t2star(v) 26 Z @A(v)\t rf (u) · n(u)ds ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent Z @A(v)\t formula: gradient is constant in each triangle rf (u) · n(u)ds = rf (u) · (a v 1 b) = rf (u) · (vj 2 ? b vk a vj 27 vk )? ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent Z @A(v)\t formula: plug in gradient formula b vk a rf (u) · n(u)ds = = (f (vj ) v vj f (v)) (v vk )? · (vj 4At +(f (vk ) f (v)) 28 (vj vk )? + v)? · (vj 4At vk )? ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent formula: area of triangle 1 At = sin 2 1 = sin 2 cos j (vj = ||vj v j ||vj v||||vj vk || = k ||v vk ||||vj vk || v) · (vj v||||vj vk ) vk || cos 29 k γk vk γj vj (v = ||v vk ) · (vj vk ||||vj vk ) vk || ESTIMATION OF LAPLACEBELTRAMI OPERATOR • Cotangent Z @A(v)\t formula: substitute v γj vj rf (u) · n(u)ds = 1 = (cot 2 k (f (vj ) γk vk f (v)) + cot 30 j (f (vk ) f (v))) 2 ∆S f (v) := A(v) (cot αi + cot βi ) (f (vi ) − f (v v ∈N (v) ESTIMATION OF LAPLACEBELTRAMI OPERATOR i 1 v • Cotangent v formula: sum on all triangles A(v) 1 f (u)dA = 2 1 f (v) = 2A(v) v αi βi vi Z A(v) vi X (cot ↵i + cot i )(f (vi ) f (v)) Mark Pauly vi 2N1 (v) X vi (cot ↵i + cot vi 2N1 (v) 31 i )(f (vi ) f (v)) ESTIMATION OF LAPLACEBELTRAMI OPERATOR • There exist also other methods that use different weights for the discrete integral • General ! formula: f (vi ) = wi • wi vertex weight • wij edge weights X wij (f (vj ) vj 2N1 (vi ) 32 f (vi )) LAPLACIAN MATRIX • We define the following matrices: •D = diag(w1,...,wn) diagonal matrix of vertex weights ! •M defined as mi,j ! 8 P > < vj 2N1 (vi ) wij , = wij , > : 0, symmetric matrix of edge weights •L= DM the Laplacian matrix 33 i = j, vj 2 N1 (vi ), otherwise. LAPLACIAN MATRIX • Then we have: 0 B B B B @ f (v1 ) · · · f (vn ) 1 0 C B C B C = LB C B A @ 34 f (v1 ) · · · f (vn ) 1 C C C C A CURVATURE FROM LAPLACEBELTRAMI OPERATOR • If we apply the Laplace-Beltrami operator (element-wise) to the coordinate function X of S, we have: ! X= 2Hn where H denotes the mean curvature and n denotes the surface normal • Therefore: H= 1 X·n 2 35 DISCRETE GAUSSIAN CURVATURE •A discrete estimation of Gaussian curvature at a vertex v is given by the angle defect of its incident triangles ! ! 0 1 @ K(v) = 2⇡ A(v) X vj 2N (v) 1 ✓j A where θj denotes the angle between vvj and vvj+1 36 DIFFERENTIAL COORDINATES vector ΔX(v) defines the differential coordinates of v with respect to its neighbors, and it approximates the local shape characteristics of surface S at v • The aplacian Mesh Processing eres neor ⇤i = 1 di ⇥ j⇤N(i) (vi v j) 37 1 ⇧ |⌅| v⇤⌅ (vi v)dl(v) SUMMARY • Surface normal at triangles and at vertices • Evaluation of curvature tensor (principal curvatures and curvature directions), Gaussian and mean curvature • Properties of a scalar field defined over the surface: • gradient • Laplace-Beltrami • Differential operator (Laplacian matrix) coordinates 38