Computer-Aided Design 39 (2007) 142–148 www.elsevier.com/locate/cad Error analysis of reparametrization based approaches for curve offsetting Hong-Yan Zhao, Guo-Jin Wang ∗ Department of Mathematics, State Key Laboratory of CAD&CG, Zhejiang University, Hangzhou 310027, China Received 22 February 2005; accepted 6 November 2006 Abstract This paper proposes an error analysis of reparametrization based approaches for planar curve offsetting. The approximation error in Hausdorff distance is computed. The error is bounded by O(r sin2 β), where r is the offset radius and β is the angle deviation of a difference vector from the normal vector. From the error bound an interesting geometric property of the approach is observed: when the original curve is offset in its convex side, the approximate offset curve always lies in the concave side of the exact offset, that is, the approximate offset is contained within the region bounded by the exact offset curve and the original curve. Our results improve the error estimation of the circle approximation approaches, as well as the computation efficiency when the methods are applied iteratively for high precision approximation. c 2006 Elsevier Ltd. All rights reserved. Keywords: Offset; Convolution; Circle approximation approaches; Error bound; Angle deviation 1. Introduction Offset curves/surfaces, also called parallel curves/surfaces, are defined as a locus of the points which are at the constant distance r along the normal from the original curves/surfaces. Offsets are widely used in various CAD/CAM areas, such as tool path generation [7,8], 3D NC machining [2,11], solid modeling [17], graphics [18] and so on. Given a planar parametric curve C(t) = (x(t), y(t))(t1 ≤ t ≤ t2 ), its offset curve with an offset radius r is defined by Cr (t) = C(t) + r N(t), where N(t) = q 2 0 0 0 y (t), −x (t) / x (t) + y 0 2 (t) is the unit normal to the original curve C(t). In general, the offset curve cannot be represented in a polynomial or rational form because of the square root term in the denominator of the unit normal N(t), and so is hard to be applied in CAD systems. During the last 20 years, a lot of methods for the offset approximation [4–6,9, 10,15,16,19–22] have been proposed and developed. In 1996, Lee et al. [12] presented an approximation method of offset curves of given Bézier curves by rational Bézier curves based on circle approximation. They approximated a unit circle with piecewise quadratic polynomial curve segments Q j (s), j = 0, . . . , n. The Hodograph curve Q0j (s) is piecewise linear; therefore, the parallel constraint C0 (t)kQ0 (s(t)) provides the reparametrization of s(t) as a rational polynomial of degree d, where d is the degree of C(t). The method yields a very small error bound as shown in tables in the literature [5,13]. In contrast, Lee et al. [13,14] approximated the reparametrization s(t), while representing the circle Q(s) exactly by a rational quadratic curve. In their methods, the error stems only from the inaccurate reparametrization function s(t), which results in a mismatch in the parallel constraint of C0 (t)kQ0 (s(t)). Lee et al. [14] presented three such reparametrization based methods, LRC, TMC and SRC. Unfortunately, the approximation error cannot be computed with the distance function which was used in the quadratic curve approximation [12]. Neither can it be estimated by using the difference function of ε(t) = kCra (t) − C(t)k2 − r 2 [4], because the term ε(t) always equals zero. Lee et al. [13,14] measured the angular deviation of Q(s(t)) from the exact offset direction N(t) by using the following error function: δ(t) = ∗ Corresponding address: Department of Mathematics, State Key Laboratory of CAD&CG, Zhejiang University, No. 38 Zheda Road, Hangzhou 310027, Zhejiang Province, China. Tel.: + 86 571 87951609x8306. E-mail address: wanggj@zju.edu.cn (G.-J. Wang). c 2006 Elsevier Ltd. All rights reserved. 0010-4485/$ - see front matter doi:10.1016/j.cad.2006.11.004 hC0 (t), Q(s(t))i2 . kC0 (t)k2 In this way, the accuracy of the algorithm is controlled by the angle deviation. The distance between the exact offset point Cr (t) and an approximated offset point Cra (t) is ε ≈ r sin β H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 Fig. 1. The exact error is over-estimated by ε1 (t) = kCra (t) − Cr (t)k. (see Fig. 1). However, this error measure considerably overestimates the approximation error. Ahn et al. [1] computed the Hausdorff distance (see Fig. 1) between the exact and approximated offset curves to estimate the approximation error. However, the method can only be used when the approximated offset is compatible [12,13] to the original curve. Generally, distance sampling can be employed, but it could not guarantee the maximum global error. In this paper, we propose a different approach to compute the Hausdorff distance to estimate the approximation error using reparametrization based methods that were proposed in [13,14]. We first divide the original curve into several segments at inflexion points. Secondly, we compute the relationships between the angular deviations. Finally the error bound can be expressed by those angles. The error bound is O(r sin2 β), where β is the angle between N(t) and Q(s). From the error bound, we observe that when the original curve is offset in its convex side, the approximated offset curve is always bounded by the exact offset curve and the original curve. The paper is organized as follows. Section 2 reviews the reparametrization based offsetting methods. Section 3 introduces the new error estimation method. In Section 4, we give some comparisons using our method. Then comes the conclusion of the paper. 2. Circle approximation approaches for curve offsetting We briefly review the reparametrization based approaches for curve offsetting in this section. The offset circle is represented by piecewise rational curve segments. The exact offset curve is then approximated by taking the vector sum of the original curve with the circle segments. Generally, a quadratic rational Bézier curve Q(s) is used to represent a circular segment as the following Q (s) = (1 − s)2 ω0 P0 + 2 (1 − s) sω1 P1 + s 2 ω2 P2 (1 − s)2 ω0 + 2 (1 − s) sω1 + s 2 ω2 s1 ≤ s ≤ s2 , , where P0 , P1 , and P2 are the control points of Q(s), ω0 , ω1 , and ω2 are weights with ω0 = ω2 = 1, ω1 = cos θ, and θ is the angle of the circular segment, see Fig. 2. 143 Fig. 2. Circular arc with quadratic rational representation. Fig. 3. Offsetting the curve segment in its convex direction. Then the offset curve is approximated by taking the vector sum of the original curve and quadratic rational Bézier curve Q(s) which is defined as Cra (t) = C (t) + r Q (s (t)), where s = s(t) is an approximated reparametrization. For instance, a linear reparametrization method based on the tangent field matching [3] is used in the MO (also called TMC in [14]) method [13] while Lee et al. [13] used two alternative different linear reparametrization methods. In the TMC method, the offset approximation error is estimated by the angle deviation between the vector Q(s) and the corresponding normal vector N(t). However, the error is considerably over-estimated since the distance due to the angle deviation does not faithfully reflect the Hausdorff distance from the exact offset curve. In this paper, we present a more precise error estimation in the Hausdorff distance. Using this result, the conventional reparametrization based methods become more practical because of the improved error estimation. 3. Error analysis In the reparametrization based approach, the distance between the original curve and the offset approximation curve is equal to the offset radius r for any parameter value. But the direction of the difference vector Cra (t) − C(t) is inconsistent with the normal direction N(t) of C(t). Therefore, the error will be introduced in the form of the associated angular deviation. Denote β to be the angle between N(t) and Q(s(t)). Let C(t + ∆t) be the point on the original curve whose normal passes through the approximated offset point Cra (t) of the curve C(t), see Figs. 3 and 5. That is, for any t ∈ [t1 , t2 ], there exists 144 H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 Fig. 4. Angles γ , δ, and β in Case 1. (b) is obtained from (a) by appending an auxiliary parallel line. Thus the bound for λ can be derived from Eqs. (3.1)–(3.3) as follows a parameter value t + ∆t and a constant λ satisfying C(t + ∆t) + λr N(t + ∆t) = C(t) + r Q(s(t)), cos γ − sin β sin (β − γ ) ≤ λ ≤ cos γ , where N(t + ∆t) is the normal of the curve at the point C(t + ∆t). Thus the approximation error in Hausdorff distance is represented by r (λ − 1). Let γ denote the angle between the normal vector N(t +∆t) and the vector Q(s(t)), and δ the angle between the difference vector C(t + ∆t) − C(t) and the vector N(t + ∆t). The relationship between angles γ and δ is derived as C (t) − C (t + ∆t) · N (t + ∆t) λ = Q (s (t)) · N (t + ∆t) + r kC (t) − C (t + ∆t)k = cos γ + · cos δ. (3.1) r Then the approximation error is obtained as follows kC (t) − C (t + ∆t)k r (λ − 1) = r cos γ − 1 + · cos δ . r We will discuss the approximation error of the offset in more detail along the convex direction and concave direction of the original curve respectively. Case 1: offset in the convex direction The angles γ , δ, and β are respectively the angles between the vector N(t + ∆t) and the vector Q(s(t)), the difference vector C(t) − C(t + ∆t) and the vector N(t + ∆t), and the normal vector N(t) and the vector Q(s(t)), see Fig. 4(a). A dotted line that is parallel to the norm N(t) is drawn from the point C(t + ∆t), see Fig. 4(b). It is easily seen from Fig. 4(b) that 0 ≤ γ ≤ β, cos β cos (β − γ ) ≤ λ ≤ cos γ . Based on the following inequalities cos β cos(β − γ ) − 1 ≥ cos2 β − 1 = −sin2 β, cos γ − 1 ≤ 0, the approximation error r (λ − 1) is obtained as −r sin2 β ≤ r (λ − 1) ≤ 0. tan 6 ABO = (3.2) (3.3) (3.4) Therefore, the approximation error is at least of O(r sin2 β) and its upper bound is zero. It indicates that the approximate offset always lies in the concave side of the exact offset curve, i.e., lies in the region bounded by the exact offset curve and the original curve. Case 2: offset in the concave direction Let ρ(t) be the curvature radius of the original curve C(t). We suppose there is no self-intersection for both the exact offset curve and the approximate offset curve, i.e., the offset radius r < ρ(t) for all t, see Fig. 5. Denote η(t) = r/ρ(t). Let A = C(t) and B = C(t) + r Q(s(t)), see Fig. 6. For each parameter t, a neighborhood Oδ (t) = {u|t − δ ≤ u ≤ t + δ} can be found so that the curve segment C (u) (u ∈ Oδ (t)) is entirely contained inside the circle with radius ρ − ε(0 < ε < ρ). Obviously, the angle 6 ABO > π/2 as the angle deviation β is very small. In 4AOB, by using laws of sins we have It can be derived from (3.5) that From Fig. 4(a) we have kC (t) − C (t + ∆t)k ≤ r sin β. or sin (π − 6 ABO − β) r = . 6 sin ABO ρ−ε and π π ≤ δ ≤ + (β − γ ) . 2 2 Therefore −sin (β − γ ) ≤ cos δ ≤ 0. Fig. 5. Offsetting the curve segment in its concave direction. r ρ−ε sin β . − cos β As γ < π − 6 ABO and 6 ABO > π/2, we have tan γ < − tan 6 ABO = sin β sin β , r → cos β − ρ−ε cos β − η (3.5) 145 H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 and (3.6), it follows that cos γ ≥ 1 − sin2 β (cos β − η)2 + sin2 β , and λ − 1 ≥ cos γ − 1 ≥ − sin2 β (cos β − η)2 + sin2 β , or cos β cos β −1 −1≤ sin2 β cos γ 1− 2 2 (cos β−η) +sin β cos β (cos β − η)2 + sin2 β = −1 (cos β − η)2 λ−1 ≤ = Fig. 6. Angles γ , δ, and β in Case 2. (b) is obtained from (a) by appending an auxiliary parallel line. ε → 0. γ ≥ β, (cos β − η)2 β β 2 cos β cos2 2 − (cos β − η)2 = 2 sin 2 (cos β − η)2 β cos β (cos β + 1) − (cos β − η)2 = 2 sin2 2 (cos β − η)2 β cos β (1 + 2η) − η2 = 2 sin2 . 2 (cos β − η)2 (3.6) Then the relation among the angles γ , δ, and β can be obtained using the concavity of the curve segment. The line started from point B that is parallel to the normal direction of the point C(t) divides the angle γ into two angles, one of which is equal to β, see Fig. 6(b). Then we have (cos β − 1) (cos β − η)2 + cos β sin2 β 2 Therefore the bound for r (λ − 1) of Case 2 is derived as follows − r sin2 β (cos β − η)2 + sin2 β β ≤ 2r sin 2 2 cos β (1 + 2η) − η2 (cos β − η)2 . (3.9) π π − (γ − β) ≤ δ ≤ . 2 2 (3.7) On the other hand, in the triangle determined by the three vertices A, B and C(t + ∆t), we have kC (t + ∆t) − C (t)k ≥ r sin γ , (3.8) and r sin γ . sin δ Thus a bound for kC(t) − C(t + ∆t)k is derived based on the above equation and the inequalities (3.7) and (3.8) as follows: r sin γ ≤ kC (t + ∆t) − C (t)k ≤ r sin γ . cos (γ − β) Then the bound for λ in Eq. (3.1) can be obtained as cos γ ≤ λ ≤ ≤ r (λ − 1) π (γ − β) + δ ≥ , 2 or kC (t + ∆t) − C (t)k = cos β cos β . ≤ cos (γ − β) cos γ From cos γ ≥ 1 − sin2 γ = 1 − tan2 γ , 1 + tan2 γ It is seen from Eq. (3.9) that the bound for the approximation error is at least O(r sin2 β). However, if the value of cos β is close to η, the denominator of the error bound will approach to zero, which will make the bound inexact or invalid. This occurs at cusp points of the offset curve. Similarly, we can compute the range of the value Q(s(t))·N(t) by symbolic computation. Thus the error bounds for the two cases can be obtained by (3.4) and (3.9) respectively. It is worthwhile to mention that the error analysis becomes much more complicated when there is self-intersection in the curve segment C(t). The global error control cannot be guaranteed as the assumption of “There exists a footpoint of Cra (t) at an original curve point C(t + ∆t) and the offset point Cra (t) will be on the normal line to the curve at the point C(t + ∆t)” does not hold. 4. Comparisons In this section, we present examples of the application of our error estimation method. Figs. 7–9 show some experimental results on the construction of approximated offset curves. The input curve of Fig. 7 is a cubic Bézier curve with 4 control points: (−0.785938, 0.891849), 146 H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 Fig. 7. (a) Cubic Bézier curve and its offset approximation curve. (b) Offset approximation after subdivisions. Fig. 8. (a) Cubic B-spline curve and its offset approximation curve. (b) Curve subdivision after knot insertion and self-intersection removal. Fig. 9. (a) Quintic B-spline curve and its offset approximation curve. (b) Offset approximation after subdivision. (−0.993306, −0.59695), (0.3, −2.5) and (0.9, −0.2). An offset radius 1.0 is used. We compare the Hausdorff distance between the offset curve and the approximant using LRC, TMC, and SRC methods. Table 1 shows the error bound of each approximation method. The Hausdorff distances are 0.3237, 0.2696, and 0.1278 respectively. Clearly, SRC outperforms LRC and TMC. If the tolerance is given by 10−1 , then the curve must be subdivided. We subdivide C(t) at the parameter value with maximum error. After subdivision, the new subdivided Bézier curve segments C1 (t) and C2 (t) are approximated by LRC, TMC, and SRC (see Fig. 7(b)). The Hausdorff distance is compared again. The input curve of Fig. 8 is a uniform cubic Bspline curve with 7 control points: (−3.01619, 2.34143), (−3.97193, 2.20842), (−1.07045, 0.0722807), (0.319568, −2.77522), (−0.152767, 2.299), (2.92416, −0.939865) and (2.8027, 3.02775). An offset radius 0.5 is used for the example. Intersection occurs on the offset curve, so we first remove the intersecting loop (see Fig. 8(b)). The curve is subdivided into Table 1 The error bound of the Hausdorff distance between the offset curve and the approximation using LRC, TMC, and SRC methods Segment LRC TMC SRC C(t) C1 (t) C2 (t) [−0.3237, 0] [−0.0124, 0] [−0.1006, 0] [−0.2696, 0] [−0.0110, 0] [−0.1936, 0] [−0.1278, 0] [−0.0088, 0] [−0.0274, 0] four cubic Bézier curve segments. Each segment has an inflexion point on it. We subdivide the segment at the inflexion point, and the original curve is subdivided finally into eight curve segments. Having introduced in Section 1, Lee et al. [13] proposed to estimate the approximation error using ε ≈ r sin β. For the curve segments Ci (t) (i = 1, 4, 5, 8), which are offset in the convex direction, our error bound is [−r sin2 β, 0], better than Lee’s error estimation. For those offset in the concave direction, Ci (t) (i = 2, 3, 6, 7), still, Table 2 shows our estimation is more effective than Lee’s. 147 H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 Table 2 Comparison of the error bounds using our estimation method and Lee’s method Segment C1 (t) C2 (t) C3 (t) C4 (t) C5 (t) C6 (t) C7 (t) C8 (t) LRC Lee’s Ours TMC Lee’s Ours SRC Lee’s Ours 0.1747 0.0193 0.0754 0.2762 0.0595 0.0647 0.0177 0.1166 [−0.0610, 0] [−0.0011, 0.0007] [−0.0231, 0.0185] [−0.1526, 0] [−0.0071, 0] [−0.0123, 0.0087] 1.0e–3 × [−0.9428, 0.6481] [−0.0272, 0] 0.1114 0.0130 0.0533 0.1386 0.0452 0.0473 0.0115 0.0814 [−0.0248, 0] 1.0e–3 × [−0.8215, 0.6526] [−0.0094, 0.0075] [−0.0384, 0] [−0.0041, 0] [−0.0231, 0.0218] 1.0e–3 × [−0.8443, 0.7123] [−0.0133, 0] 0.1132 0.0126 0.0488 0.1382 0.0457 0.0467 0.0117 0.0804 [−0.0256, 0] 1.0e–3 × [−0.7648, 0.6075] [−0.0080, 0.0064] [−0.0382, 0] [−0.0042, 0] [−0.0225, 0.0212] 1.0e–3 × [−0.8697, 0.7338] [−0.0129, 0] Table 3 Comparisons between offset approximation methods Segment Lee’s method Ahn’s method LRC TMC SRC C(t) C1 (t) C2 (t) 1.24 0.0443 0.0256 0.1030 0.0391 0.0430 [−0.2780, 0] [−0.1133, 0] [−0.1109, 0] [−0.1235, 0] [−0.0496, 0] [−0.0636, 0] [−0.0970, 0] [−0.0435, 0] [−0.0487, 0] No comparison has ever been made between the reparametrization based method with other offset approximation methods. Table 3 shows the comparison of the Hausdorff distance between Lee et al. [12], Ahn et al. [1] and LRC, TMC, and SRC methods. The input curve is a quintic Bézier curve with 6 control points: (3, −1), (4, 2), (4.5, 2), (5.5, 1.5), (6.5, 0) and (7, −1), shown in Fig. 9. The Hausdorff distance is shown in the second row in Table 3. If the given tolerance is given by 10−1 , only the SRC method can meet the need. We subdivide C(t) at the farthest point from the line passing through both end points of C(t). Table 3 shows Lee’s method, Ahn’s method, and the SRC method yield similar approximation results. 5. Conclusion In this paper, we present an error analysis for the reparametrization based approaches for curve offsetting. The offset curve is considered as an envelope curve of the swept circle along the original curve. Our method measures the Hausdorff distance between the exact and approximated offsets. A tight error bound has been obtained in this paper, which also reveals some interesting properties of the approaches. Our work has improved the error estimation for the reparametrization based approaches and makes the approaches more practical and convenient. Acknowledgements We wish to thank Dr. Ligang Liu for his great help in improving the exposition of the paper. We are also grateful to Prof. Myung-Soo Kim for his valuable comments and constructive suggestions. This work was supported by the National Basic Research Program of China (No. 2004CB719400), the National Natural Science Foundation of China (No. 60673031 & No. 60333010) and the National Natural Science Foundation for Innovative Research Groups (No. 60021201). References [1] Ahn YJ, Kim YS, Shin Y. Approximation of circular arcs and offset curves by Bézier curves of high degree. Journal of Computational and Applied Mathematics 2004;167(2):405–16. [2] Chen YJ, Ravani B. Offset surface generation and contouring in computeraided design. Journal of Mechanisms, Transmissions and Automation in Design: ASME Transactions 1987;109(3):133–42. [3] Cohen S, Elber G, Bar Yehuda R. Matching of freedom curves. Computer Aided Design 1997;29(5):369–78. [4] Elber G, Cohen E. Error bounded variable distance offset operator for free form curves and surfaces. International Journal of Computational Geometry and Application 1991;1(1):67–78. [5] Elber G, Lee IK, Kim MS. Comparing offset curve approximation method. IEEE Computer Graphics and Application 1997;17(3):62–71. [6] Elber G, Cohen E. Offset approximation improvement by control points perturbation. In: Lyche T, Schumaker LL, editors. Mathematical methods in computer aided geometric design II. New York: Academic Press; 1992. p. 229–37. [7] Hansen A, Arbab F. An algorithm for generating NC tool paths for arbitrarily shaped pockets with islands. ACM Transactions on Graphics 1992;11(2):152–82. [8] Held M. On the computational geometry of pocket machining. Berlin (Germany): Springer-Verlag; 1991. [9] Hoscheck J. Spline approximation of offset curves. Computer Aided Geometric Design 1988;20(1):33–40. [10] Klass R. An offset spline approximation for plane cubic splines. Computer Aided Design 1983;15(4):297–9. [11] Kuragano T, Sasaki N, Kikuchi A. The FRESDAM system for designing and manufacturing free-form objects. In: Martin R, editor. USA–Japan cross bridge. Flexible automation, vol. 2. 1988. p. 931–8. [12] Lee IK, Kim MS, Elber G. Planar curve offset based on circle approximation. Computer Aided Design 1996;28(8):617–30. [13] Lee IK, Kim MS, Elber G. New approximation methods of planar offset and convolution curves. In: Strasser W, Klein R, Rau R, editors. Geometric modeling: Theory and practice. 1997. p. 83–101. 148 H.-Y. Zhao, G.-J. Wang / Computer-Aided Design 39 (2007) 142–148 [14] Lee IK, Kim MS, Elber G. Polynomial/rational approximation of Minkowski sum boundary curves. Graphical Models and Image Processing 1998;60(2):136–65. [15] Li YM, Hsu VY. Curve offsetting based on Legendre series. Computer Aided Geometric Design 1998;15(7):711–20. [16] Maekawa T. An overview of offset curves and surfaces. Computer Aided Design 1999;31(3):165–73. [17] Patrikalakis NM, Prakash PV. Free-form plate modeling using offset surfaces. Journal of Offshore Mechanics and Arctic Engineering 1988; 110(3):287–94. [18] Patrikalakis NM, Gursoy HN. Shape interrogation by medial axis transform. In: Ravani B, editor. Proceedings of the 16th ASME design [19] [20] [21] [22] automation conference: Advances in design automation. Computer Aided and Computational Design 1990;23(1):77–88. Pham B. Offset approximation of uniform B-splines. Computer Aided Design 1988;20(8):471–4. Piegl LA, Tiller W. Computing offsets of NURBS curves and surfaces. Computer Aided Design 1999;31(2):147–56. Sederberg TW, Buehler DB. Offsets of polynomial Bézier curves: Hermite approximation with error bounds. In: Lyche T, Schumaker LL, editors. Mathematical methods in computer aided geometric design II. New York: Academic Press; 1992. p. 549–58. Tiller W, Hanson EG. Offsets of two-dimensional profiles. IEEE Computer Graphics and Application 1984;4(9):36–46.