www.scichina.com info.scichina.com www.springerlink.com The sharp upper bound on the distance between a parametric patch and its interpolated triangle ZHANG RenJiang1,2 † & WANG GuoJin2 1 College of Science, China Jiliang University, Hangzhou 310018, China; 2 State Key Laboratory of CAD and CG, Zhejiang University, Hangzhou 310027, China In computer aided geometric design (CAGD) and computer graphics, it is a general manipulation to approximate a surface by triangulation mesh. Thus a key problem is to estimate the error of the approximation. So far, many papers have given various estimate bounds of the distance between a parametric patch of a C 2 surface and an arbitrary triangle whose vertices are on the patch, but these estimates are all imperfect, some of them have large error, some of them have complicated representation formulae. By using a succinct new method, a sharp upper estimate of the maximum distance between a patch and a triangle is obtained and a strict proof is given. This is very valuable for CAGD. computer aided geometric design, parametric patch, triangulation, bound of approximation 1 Introduction Given a parametric patch of a C 2 surface and an arbitrary triangle whose vertices are on the patch, it is an important task to determine the maximal distance between the patch and the triangle within the parametric domain at which the triangle is located. If the maximal distance is smaller than a tolerance specified by the user, then the patch can be regarded as sufficiently flat and hence it can be replaced by the triangle in many applications such as intersection testing, display, rendering and so on. It is difficult to obtain the exact value of the maximal distance, and many papers have investigated the bound estimate of the maximal distance. Lane and Carpenter[1] gave a formula for calculating an upper bound of the distance for the case of the orthogonal triangle. This formula was later improved by Filip et al.[2] . In 1992, Sheng and Hirsch[3] have ulteriorly generalized it to Received August 11, 2006; accepted July 4, 2007 doi: 10.1007/s11432-008-0018-0 † Corresponding author (email: zrj@cjlu.edu.cn; gjwang@hzcnc.com) Supported by the National Basic Research Program of China (Grant No. 2004CB719400), the National Natural Science Foundation of China (Grant Nos. 60673031 and 60503057) and the Natural Science Foundation of Zhejiang Province (Grant No. Y607034) Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 the case of arbitrary triangles. Their result can be written as follows: Theorem A. Let S(u, v) be a C 2 parametric surface, let T ∈ [a, b] × [c, d] be a triangle in the parametric space, and let l(u, v) be an arbitrary triangle interpolating the surface S(u, v), i.e., three vertices (A, B, C) of the triangle l(u, v) satisfy the following expressions: S(A) = l(A), S(B) = l(B), S(C) = l(C). Then, 2 sup kS(u, v) − l(u, v)k 6 L2 (M1 + 2M2 + M3 ), 9 (u,v)∈T (1) where L is the maximal edge length of the triangle ABC , and 2 2 2 ∂ S(u, v) ∂ S(u, v) ∂ S(u, v) . ; M3 = sup M1 = sup ; M2 = sup ∂u2 ∂u∂v ∂v 2 (u,v)∈T (u,v)∈T (u,v)∈T Piegl et al.[4] and Brunet et al.[5] applied the above estimate to approximate NURBS surfaces and trimmed surfaces. Marc et al.[6] proposed a concept named the directed triangulation and claimed to have improved the estimates, but the representation formulae of this improvement are very complicated and require many times for calculation. Later, Sun et al.[7] obtained a new estimate which is similar to the expression (1), that is the constant term 29 in expression (1) can be reduced to 18 , but this is still not a sharp estimate and their proof is also not strict. Recently, ref. [8] gave some minor improved estimates. Since the estimate bound will directly determine requisite times of subdividing a triangle, any coarse or complicated estimate will increase unfruitful calculation and bring on a computation slowdown, and it is an important project in CAGD to seek the sharpest estimate. In this note we use a succinct new method to solve the problem and get a sharp estimate bound. The result can be summed up as follows. Theorem 1. Let T , L, S(u, v) and l(u, v) be the same as in Theorem A. Then 1 sup kS(u, v) − l(u, v)k 6 L2 (M1 + M2 + M3 − min{M1 , M2 , M3 }), 8 (u,v)∈T (2) and the above upper bound is sharp. It need to point out that the estimate (2) not only is the sharp estimate, but also has greatly improved Sun et al’s result, that is, our estimate bound is just one half large as Sun et al.’s[7] one when M1 = M2 = M3 . 2 Lemmas and their proofs To prove the theorem, we need the following two lemmas. Lemma 1. Suppose there is a lozenge with its center being superposed on the origin of coordinates, and let the distance between its two opposite edges be equal to L. Then there does not exist such a triangle which contains the origin of coordinates, whose maximal edge length is equal to L, but whose three vertexes lie in the outside of the above lozenge. Proof. The lemma holds apparently, so we omit its proof. Lemma 2. Suppose a triangle contains the origin of coordinates, its maximal edge length is equal to L and the coordinates of its three vertexes are (xi , yi )(i = 1, 2, 3) respectively, then 114 ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 for any nonnegative real numbers a, b, c, there at least exists a vertex of the triangle such that its coordinate (xi , yi )(i ∈ {1, 2, 3}) satisfies the following inequality: ax2i + 2b|xi yi | + cyi2 6 L2 (a + b + c − min{a, b, c}). 4 Proof. Suppose the conclusion of the lemma is not true. That is (xi , yi ), the coordinates of the three vertexes of the triangle satisfy L2 (a + b + c − min{a, b, c}), (i = 1, 2, 3). 4 This shows that the three vertexes of the triangle lie in the outside of the domain surrounded by the following planar implicit curve: ax2i + 2b|xi yi | + cyi2 > L2 (a + b + c − min{a, b, c}). (3) 4 Since the graphics of the implicit curve (3) is symmetrical about the x-axis or the y -axis, we only need to consider a part of its graphics in the first quadrant, and the other parts of it can be considered by symmetry. Therefore, we can show that the three vertexes of the triangle can’t lie in the outside of the domain surrounded by the planar implicit curve (3) according to the following distinct cases. 1. b = 0. 1) ac = 0. Without loss of generality, we assume that c = 0 (if both a and c are equal to 0, then 2 the lemma holds apparently). In this case, the expression (3) can be simplified as x2 = L4 , then it is easy to see that the three vertexes of the triangle lie in the outside of the domain surrounded by the two straight lines: x = − L2 ; x = L2 . This is impossible. 2) ac 6= 0. In this case the expression (3) can be simplified as ax2 + 2b|xy| + cy 2 = L2 (a + c), 4 which denotes an ellipse. It is easy to see that the three vertexes of the triangle lie in the outside of the domain surrounded by the ellipse, thus they have to lie in the outside of the domain surrounded by an inscribed lozenge of the ellipse. Choosing such a lozenge which is surrounded by the following four straight lines: x y x y p p + Lp = 1; + Lp = 1; L c a L c 1+ a 1+ c −2 1+ a 1 + ac 2 2 2 x y x y p p + Lp = 1; + Lp = 1. L c a L c 1+ a −2 1+ c −2 1+ a − 2 1 + ac 2 ax2 + cy 2 = Direct calculation indicates that the distance between the two opposite edges of the lozenge is equal to L. Following Lemma 1, this is impossible. 2. b 6= 0. 1) b2 = ac. Assume, without loss of generality, that a > c. It is easy to derive that min{a, b, c} = c in this case. By the expression (3) one can see that the three vertexes of the triangle lie in the outside of the lozenge surrounded by the following four straight lines: √ √ √ √ L√ L√ ax + cy = a + b; ax − cy = a + b; 2 2 √ √ √ √ L√ L√ − ax + cy = a + b; − ax − cy = a + b. 2 2 ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 115 Direct calculation shows that the distance between the two opposite edges of the lozenge is equal to L. By Lemma 1, this is impossible. 2) b2 < ac. It can be proved that the graphics, of the implicit curve denoted by the expression (3), which is located in the first quadrant and is the part of an ellipse; and q the intersection be- tween the part and two coordinate axes, x-axis and y -axis, is two points ( L2 a+b+c−min(a,b,c) , 0), a q (0, L2 a+b+c−min(a,b,c) ) respectively; also the symmetrical points of the above two points about c q q a+b+c−min(a,b,c) L L the x-axis and y -axis are (− 2 , 0), (0, − 2 a+b+c−min(a,b,c) ), respectively. It a c is easy to see that the three vertexes of the triangle have to lie in the outside of the lozenge whose vertexes are the above four points.q Simple calculation shows the distance between the two opposite edges of the lozenge is equal to L a+b+c−min(a,b,c) a+c > L. By Lemma 1, this is impossible. 3) b > ac. Without loss of generality, suppose that a > c, in this case min{a, b, c} = c. Then the graphics of the implicit curve (3) is equal to a part of an ellipse or a part of a hyperbola. If it denotes a part of an ellipse, then c > 0. According to the calculation of case 2), this is impossible. Otherwise, if it denotes a part of a hyperbola, noticing that the center of the hyperbola lie in the origin of the coordinates, we now estimate the length of the radius of a circle which is tangential with the hyperbola and whose center lies in the origin of the coordinate. The parametric equation of the circle can be written as x = r cos θ; y = r sin θ. Substituting them into the expression (3) yields: L2 r 2 (a cos2 θ + 2b sin θ cos θ + c sin2 θ) = (a + b). 4 Applying triangle identity, the above expression can be rewritten as s ! 2 a−c a+c L2 2 2 r b + sin (2θ + φ) + = (a + b), 2 2 4 2 where tan φ = a−c 2b and − π2 < φ < π2 , which leads to r2 > L2 a+b q 4 b2 + ( a−c )2 + 2 > a+c 2 L2 L =⇒ r > . 4 2 (4) When the equality sign holds in the expression (4) the circle and the hyperbola is tangent each . Therefore it is easy other. In this case, we have sin(2θ + φ) = 1, which gives that θ = π−2φ 4 to derive that θ is a sharp angle, so the circle and the hyperbola are tangent in the first quadrant. Combining the expression (4) one can see that the distance between their common tangent line and the origin of the coordinates is larger than L2 . Thus by the symmetry, it is easy to see that there exists a lozenge satisfying all conditions of Lemma 1. This is also impossible. It thus completes the proof of Lemma 2. 3 The proof of the theorem Now begin to prove Theorem 1. Let T , L, S(u, v) and l(u, v) be the same as in Theorem A. Then 1 sup kS(u, v) − l(u, v)k 6 L2 (M1 + M2 + M3 − min{M1 , M2 , M3 }), 8 (u,v)∈T Theorem 1. 116 ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 and the above upper bound is sharp. Proof. Let a vector-valued function e(u, v) = S(u, v) − l(u, v) and e(u, v) · e(u, v) = d(u, v). Since the domain T is compact, the two variable function d(u, v) attains its maximum at some point p0 ∈ △ABC . We distinguish two cases to discuss. Case 1. The point P0 is on the boundary of T . Without loss of generality, assume P0 ∈ AB . Writing S(u, v)|(u,v)∈AB = Ŝ(t), ((u, v) = (1 − t)A + tB, t ∈ [0, 1]), then applying the result in ref. [2], we have 1 sup kS(u, v) − l(u, v)k = sup kS((1 − t)A + tB) − l((1 − t)A + tB)k 6 sup kŜ ′′ (t)k 8 t∈[0,1] (u,v)∈T t∈[0,1] 2 2 2 ∂ S du 2 ∂s dv 1 ∂s du dv = sup + 2 ( )2 . ( ) +2 2 8 ∂u dt ∂u∂v dt dt ∂v dt (u,v)∈AB Noting that du dt = uB − uA , dv dt = vB − vA , we have sup kS(u, v) − l(u, v)k (u,v)∈T 1 (uB − uA )2 M1 + 2|uB − uA ||vB − vA |M2 + (vB − vA )2 M3 8 1 6 (uB − uA )2 (M1 + M2 ) + (vB − vA )2 (M2 + M3 ) 8 1 (uB − uA )2 (M1 + M2 ) + (vB − vA )2 (M2 + M3 ) 6 8 1 (uB − uA )2 + (vB − vA )2 (M1 + M2 + M3 − min{M1 , M2 , M3 }) 6 8 1 6 L2 (M1 + M2 + M3 − min{M1 , M2 , M3 }). 8 The point P0 is in the interior of T , then ∂d(u, v) ∂d(u, v) (P0 ) = (P0 ) = 0, ∂u ∂v 6 Case 2. so that ∂e ∂e (P0 ) = e(P0 ) · (P0 ) = 0. (5) ∂u ∂v By the form-invariability of partial derivative function about coordinate shifting, we can suppose P0 lies in the origin of coordinates. Also let w = A − P0 and write w = (d cos θ, d sin θ), where d = kA − P0 k and θ is the angle between the line segment AP0 and the u axis (see Figure 1), and introduce an accessorial function g(t) = e(P0 + tw), we have g(0) = e(P0 ), g(1) = e(A). Then integrating by parts, we can obtain Z t ′ g(t) = g(0) + g (0)t + g′′ (x)(t − x)dx. e(P0 ) · 0 Setting t = 1 in the above expression we have ′ g(1) = g(0) + g (0) + Z 0 and expanding out gives e(A) = e(P0 ) + 1 g′′ (x)(1 − x)dx, ∂e ∂e (P0 )d cos θ + (P0 )d sin θ + I, ∂u ∂v ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 117 Figure 1 θ is the angle between the line segment AP0 and the u axis. where I= 1 ∂2S ∂2S 2 2 (P + xw)d cos θ + 2 (P0 + xw)d2 cos θ sin θ 0 2 ∂u ∂u∂v 0 ∂2S 2 2 + (P0 + xw)d sin θ (1 − x)dx. ∂v 2 Z Taking the dot product of the vector e(A) with the vector e(P0 ), and noting the following two equalities: ∂d(u, v) ∂d(u, v) (P0 ) = (P0 ) = 0 and e(A) = 0, ∂u ∂v which yields 0 = e(P0 )e(P0 ) + e(P0 )I, then we get Z 1 ke(P0 )k 6 kIk 6 (d2 cos2 θM1 + 2d2 | sin θ cos θ|M2 + d2 sin2 θM3 ) (1 − x)dx 0 1 = (d2 cos2 θM1 + 2d2 | sin θ cos θ|M2 + d2 sin2 θM3 ). 2 Since the coordinates (u, v) of the vertex A can be written as (d cos θ, d sin θ), the above expression gives 1 ke(P0 )k 6 (u2 M1 + 2|uv|M2 + v 2 M3 ). 2 The above expression still holds obviously for the vertex B or the vertex C , following Lemma 2 we get 1 ke(P0 )k 6 L2 (M1 + M2 + M3 − min{M1 , M2 , M3 }). 8 Second, the following examples show that the coefficient 18 in Theorem 1 cannot be reduced. Let S(u, v) = (x(u, v, y(u, v), z(u, v))=(u, v, 1 − u2 − v) and suppose that the corresponding parameters (u, v) of the three vertexes A, B, C of the △ABC are (1, 0),(−1, 0),(0, 1), and 118 ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 let T be the domain surrounded by the △ABC . The coordinates of points l(A), l(B), l(C) on the surface S(u, v) are (1, 0, 0), (−1, 0, 0),(0, 1, 0) respectively. It is easy to compute that sup kS(u, v) − l(u, v)k = sup |1 − u2 − v| = 1 M1 = 2, M2 = 0, M3 = 0 and L = 2. (u,v)∈T (u,v)∈T Thus 1 sup kS(u, v) − l(u, v)k = L2 (M1 + M2 + M3 − min{M1 , M2 , M3 }) = 1. 8 (u,v)∈T This shows that the coefficient 81 cannot be reduced. Finally, let S(u, v) = (x(u, v, y(u, v), z(u, v))=(u, v, u2 + 2uv + v 2 − 1), suppose that the corresponding parameters (u, v) of three vertexes A, B, C of the △ABC are ( 12 + ǫ, 12 − ǫ),( 12 − ǫ, 12 + ǫ), (− 12 , − 12 ) respectively. Suppose the points l(A), l(B), l(C) lie on the surface S(u, v). Simple computation shows that sup kS(u, v) − l(u, v)k = sup |u2 + 2uv + v 2 − 1| = 1, (u,v)∈T (u,v)∈T where T is the domain √ surrounded by the △ABC . Also it is easy to calculate M1 = 2, M2 = 2, M3 = 2 and L = 2(1 + ǫ), so 1 2 L (M1 + M2 + M3 − min{M1 , M2 , M3 }) = 1 + ǫ −→ 1 (ǫ −→ 0). 8 This indicates that the M1 + M2 + M3 − min{M1 , M2 , M3 } in the estimate bound of Theorem 1 is sharp. Thus the proof of the theorem is completed. 1 Lane J M, Carpenter L. A generalized scan line algorithm for the computer display of parametrically defined surface. Comput Vision Graph Image Proc, 1979, 11: 290–297 2 Filip D, Magedson R, Markot R. Surface algorithm using bounds on derivatives. Comput Aided Geom Des, 1986, 3: 295– 311 3 Sheng X, Hirsh B E. Triangulation of trimmed surface in parametric space. Comput-Aided Des, 1992, 24: 437–444 4 Piegl L, Richard A. Tessellating trimmed NURBS surfaces, Comput-Aided Des, 1995, 27: 16–26 5 Brunet P, Vigo M. Piecewise linear approximation of trimmed surfaces. In: Farin G, Hagen H, Noltemeier H, eds. Geometric Modelling, 1995, Computing Suppl. 10. Berlin: Springer, 1995. 341–356 6 Marc V A, Núria P G, Pere B C. Directional adaptive surface triangulation. Comput Aided Geom Des, 1999, 16: 107–126 7 Sun W, Bradley C, Zhang Y F, et al. Cloud data medelling employing a unified, non-redundant triangular mesh, ComputAided Des, 2001, 33: 83–193 8 Zhang R J, Wang G J. The error estimates for approximating parametric surface by interpolated plane triangular patch. Math Num Sin (in Chinese), 2004, 26(2): 169–178 ZHANG RenJiang et al. Sci China Ser F-Inf Sci | Feb. 2008 | vol. 51 | no. 2 | 113-119 119