ARTICLE IN PRESS
Computers & Graphics 29 (2005) 594–605 www.elsevier.com/locate/cag
Technical section
Rational cubic spline interpolation with shape control Zulfiqar Habiba, Muhammad Sarfrazb,, Manabu Sakaia a
Department of Mathematics and Computer Science, Kagoshima University, Koorimoto 1-21-35, Kagoshima 890-0065, Japan b Department of Information and Computer Science, King Fahd University of Petroleum and Minerals, KFUPM # 1510, Dhahran 31261, Saudi Arabia
Abstract A rational cubic spline, with shape control parameters, has been discussed here with the view to its application in computer graphics. It incorporates both conic sections and parametric cubic curves as special cases. An efficient scheme is presented which constructs a curve interpolating a set of given data points and allows subsequent interactive alteration of the shape of the curve by changing the shape control and shape preserving parameters associated with each curve segment. The parameters (weights), in the description of the spline curve can be used to modify the shape of the curve, locally and globally. The rational cubic spline retains parametric C 2 smoothness. The stitching of the conic segments also preserves C 2 continuity at the neighboring given points. An exact derivative as well as a very simple distance-based approximated derivative schemes are presented to calculate control points. The curve scheme is interpolatory and can plot parabolic, hyperbolic, elliptic, and circular splines independently as well as segments of a rational cubic spline. We discuss complex cases of elliptic arcs in space and introduce intermediate point interpolation scheme which can force the curve to pass through a given point between any segments. r 2005 Elsevier Ltd. All rights reserved. Keywords: Curves and surfaces; Rational cubic spline; Conic; Shape preserving
1. Introduction A common problem, in computer graphics, is to design a curved outline by stitching small pieces of curves together. Piecewise rational cubic spline functions provide powerful tools for designing curves, surfaces, and some analytic primitives such as conic sections that are widely used in engineering design and various computer graphics applications [1,2]. These applications may represent a font outline [3,4], a rounded corner of an object, or may be a smooth fit to given data [5,6]. Several curve segments that Corresponding author. Tel.: +966 3 860 2763; fax: +966 3 860 1562. E-mail addresses:
[email protected] (Z. Habib),
[email protected] (M. Sarfraz),
[email protected] (M. Sakai).
compose a desired curve outline can have different mathematical descriptions. For example, the outline of the character ‘‘S’’ appears to be composed have straight lines, conics, and cubics. A single mathematical formulation for the precise definition of various types of geometry shapes is one of the major advantages of the rational cubic spline functions. Our research aims to develop a piecewise parametric curve representation scheme capable of representing shape outlines. In [7], C 1 rational cubic splines with exact derivatives at their control points were used. We introduce a similar interpolant with a very simple distance-based approximated derivative scheme and achieve fine results. Our scheme is also simpler than the area-based derivative scheme in [8]. Our research describes a parametric C 1 and C 2 rational cubic spline representation possessing a family of shape control parameters. This family of shape
0097-8493/$ - see front matter r 2005 Elsevier Ltd. All rights reserved. doi:10.1016/j.cag.2005.05.010
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
parameters has been utilized to produce straight line segments, conics, and cubics. The ability to maintain a reasonable amount of continuity (C 2 ) between conic and cubic arcs, estimated end derivatives, conic (circular, elliptical, parabolic, and hyperbolic) splines, circular arcs for given radius or center, elliptic arcs in space and intermediate point interpolation are further achievements in this research. In [7,9], the end derivatives are determined by the user, which is not convenient. Moreover, conics were not discussed at all. We have estimated most suitable end derivatives for more pleasing results. In [10], cubic and conic segments are joined with G1 continuity which is not acceptable for some practical applications. The intermediate point interpolation scheme and circular arcs, presented in [11], are not practical as the space curves and exact circular arcs in that way. Ref. [12] offered intermediate point interpolation scheme with C 0 continuity at neighborhood points. Meek et al. [13] presented G 1 continuity in their recent research work on constrained guided curve scheme. They used a rational quadratic function. We use a rational cubic function and achieve better continuity (C 2 ). In [14], a rational quadratic spline is used to represent a circular spline. We have used a rational cubic spline to achieve the same result. We have used a very simple algorithm for any type of planer or space curve with parallel or non-parallel end tangents. Our scheme can generate exact circular and elliptical arcs. We have applied degree elevation techniques on rational quadratic spline as mentioned in [15–17]. A Non-uniform rational B-spline (NURBS) representation of an ellipse is given in [17]. We have improved this technique to handle any type of elliptic arcs, even space arcs. In addition, our scheme has the following properties, which may lead to a more useful approach to curve and surface design in CAGD.
Most of the results are visualized with their associated curvature plots for easy comparison between different schemes. The benefit of using such curves in the design of surfaces, in particular surfaces of revolution and swept surfaces, is the control of unwanted flat spots and undulations. This paper has been organized in such a way that a parametric rational cubic spline scheme is considered in the next section. The analysis of the designing curve is presented in Section 3. The determination of the approximated and exact tangents at the given points is explained in Section 4. In this section, we also present a scheme to calculate the end derivatives (tangents). We discuss conditions for conics and straight line segments in Section 5. This section also covers all types of circular and elliptical arcs in space and introduces a very powerful method for intermediate point interpolation. Examples are discussed in Section 6. Finally, our conclusions are presented in the last section. 2. The rational cubic spline The cubic spline is the spline of the lowest degree with C 2 continuity. C 2 continuity meets the needs of most problems arising from engineering and mathematical physics. Rational cubic spline functions of lower degree are numerically simple, stable, and fundamental of all rational space curves. Let F i 2 Rm ; i ¼ 1; . . . ; n; be a given set of points at the distinct knots ti 2 R, with unit interval spacing. Consider a first degree parametric piecewise rational function for the straight line segment between F i and F iþ1 LðtÞ Li ðtÞ ¼
2
The curve has C continuity between the rational cubic arcs and between cubic and conic arcs. Most suitable end derivatives are estimated. A distance-based approximated derivative scheme is also used to compute the required control points. Tangent vectors vary continuously along the curve preserving C 1 continuity. Any part of the rational cubic spline can represent a conic (with exact circle and ellipse) or a straight line segment using the same interpolant. An intermediate point interpolation scheme has been introduced for use in guided curves. Our scheme can handle any kind of elliptic arc in space.
595
ð1 sÞai F i þ sbi F iþ1 , ð1 sÞai þ sbi
(2.1)
where t ti ; hi ¼ tiþ1 ti . hi We apply degree elevation formula [1, p. 104] to get quadratic rational Be´zier function
s¼
QðtÞ Qi ðtÞ ð1 sÞ2 ai F i þ sð1 sÞgi U i þ s2 bi F iþ1 , ð2:2Þ ð1 sÞ2 ai þ sð1 sÞgi þ s2 bi where U i may be taken as the point of intersection of tangents at F i and F iþ1 (see Fig. 1). Applying again degree elevation, we get rational cubic Be´zier function ¼
PðtÞ Pi ðtÞ ¼
ð1 sÞ3 ai F i þ sð1 sÞ2 ðai þ gi ÞV i þ s2 ð1 sÞðbi þ gi ÞW i þ s3 bi F iþ1 , ð1 sÞ2 ai þ sð1 sÞgi þ s2 bi
ð2:3Þ
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
596
positivity need to be presented in the description of the design curve.
Ui
V2i
W2 i W3i
Conic V3i
Cubic
Straight line Fi
V1i
W1i
F
i+1
For the constraints, ai 40, bi 40, and gi 4 ai ; bi , 8i, it is very obvious that the rational cubic is characterized as a Bernstein–Be´zier form. The case for default values of the shape parameters ai ¼ 1 ¼ bi and gi ¼ 2 is that of a cubic Hermite interpolation. Thus following the Bernstein–Be´zier theory, the curve segment Pi ðtÞ lies in the convex hull fF i ; V i ; W i ; F iþ1 g. It also follows the variation diminishing property within the convex hull, i.e., any straight line crossing the control polygon of fF i ; V i ; W i ; F iþ1 g does not cross the curve more than its control polygon.
Fig. 1. Plot of PðtÞ with V i ; W i from (2.4) straight line, (2.5) conic and (2.6) cubic.
3.1. Point and interval tension
which is a straight line segment between F i and F iþ1 with control points
The following ‘tension’ properties of the rational Hermite form are now immediately apparent from (2.3) and (2.6), see Fig. 2. Point tension: Accentuated point tension can be achieved by considering ai1 ¼ bi ! 0. The point tension property holds from both right and left of ti , where the spline interpolant becomes C 0 . Thus, this case allows the introduction of a tangent discontinuity at ti .
2ai F i þ bi F iþ1 , 2ai þ bi ai F i þ 2bi F iþ1 W 1i ¼ , ð2:4Þ ai þ 2bi and weight gi ¼ ai þ bi . Similarly function (2.3) is a conic curve between F i and F iþ1 with following control points V 1i ¼
ai F i þ gi U i ¼ , ai þ gi b F iþ1 þ gi U i W 2i ¼ i . ð2:5Þ bi þ gi Thus only one interpolant (2.3) is enough for a straight line segment, a conic arc and a cubic arc. This is a C 1 Hermite function where
lim V i ¼ F i
ai !0
lim Pi ðtÞ ¼
ai !0
V 2i
ai Di , gi þ ai bi W 3i ¼ F iþ1 Diþ1 . ð2:6Þ gi þ bi These control points can be achieved by imposing the Hermite interpolation conditions V 3i ¼ F i þ
Pðti Þ ¼ F i
and
Pð1Þ ðti Þ ¼ Di ; 8i.
and
ð1 sÞ2 gi F i þ sð1 sÞðgi þ bi ÞW i þ s2 bi F iþ1 . ð1 sÞgi þ sbi ð3:1Þ
lim W i ¼ F iþ1
bi !0
lim Pi ðtÞ ¼
bi !0
and
ð1 sÞ2 ai F i þ sð1 sÞðgi þ ai ÞV i þ s2 gi F iþ1 . ð1 sÞai þ sgi ð3:2Þ
See Fig. 2(b), where point tension is increased at the third point by decreasing the values of a3 and b2 .
(2.7)
3. Design curve analysis The parameters ai , bi , and gi are mainly meant to be used freely to control the shape of the curve. At the same time, for the convenience of the designer, it is also required that the ideal geometric properties of the curve are not lost. Such geometric properties as the variation diminishing property, the convex hull property, and
(a)
(b)
(c)
Fig. 2. Demonstration of shape parameters using distancebased derivatives (C 1 continuity). (a) Default: ai ¼ 1 ¼ bi1 ; gi ¼ 2. (b) Point tension: a3 ¼ 0:2 ¼ b2 . (c) Interval tension: g2 ¼ 20.
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
Interval tension: The interval shape property is obvious from the following limit behavior. That is, the increase in the shape parameter gi in any interval i tightens the curve towards its chord and the resulting rational spline interpolant is C 1 at ti and tiþ1 . lim V i ¼ F i ;
gi !1
lim W i ¼ F iþ1
gi !1
and
lim Pi ðtÞ ¼ ð1 sÞF i þ sF iþ1 .
gi !1
ð3:3Þ
See Fig. 2(c), where interval tension is increased for the second segment by increasing the value of g2 .
4. Tangent vectors There are different choices for the tangent vector Di at F i , which can be opted in a practical implementation for the computation of a curve with specific amount of smoothness. For spline, some reasonable tangent approximation method can be used. The distance-based approximations are found to be reasonably good in achieving pleasing smoothness.
For the tangent vector Di at F i , the end conditions are defined as D1 ¼ 2ðF 2 F 1 Þ
ð4:1Þ
This choice will control the direction of the curve properly at the end segments. The segments at the interior points, for i ¼ 2; 3; . . . ; n 1, are given by Di ¼ ai ðF i F i1 Þ þ ð1 ai ÞðF iþ1 F i Þ,
(4.2)
where ai ¼
jF iþ1 F i j . jF iþ1 F i j þ jF i F i1 j
which lead to the tridiagonal linear system of equations ai1 g g b Di1 þ i1 þ i Di þ i Diþ1 bi1 bi1 ai ai gi1 þ ai1 gi þ bi ¼ Di1 þ Di , bi1 ai i ¼ 2; . . . ; n 1, ð4:5Þ where Di ¼ F iþ1 F i .
(4.6)
This system is diagonally dominant and hence provides a unique solution. It can be solved by using some tridiagonal linear system solver like the LU decomposition method. For our purposes, exact derivatives may be computed from (4.5) together with the supposed end conditions (Fig. 3(a)) or from distance-based end derivatives using (4.1) (Fig. 3(b)). The end conditions used here may not be appropriate for the objectives of this paper. Therefore a reasonable choice is made in the next section which produces the ‘‘S’’-shaped curve in Fig. 3(c). The difference between these curves can best be determined from curvature plots shown in Fig. 4. 4.3. Estimation of end tangent vectors
4.1. Distance-based approximated derivatives
F3 F1 , 2 F n F n2 . Dn ¼ 2ðF n F n1 Þ 2
597
A reasonable choice, which is more appropriate for the curve scheme of this paper, is presented here. We suppose the first three non-collinear given points F 1 , F 2 , F 3 and the last three non-collinear given points are F n2 , F n1 , F n as shown with disk in Figs. 5(a) and 5(b), respectively. For the tangent at the first point F 1 , let y1 be the angle between F 3 F 1 and F 2 F 1 . Let F 02 be the rotation of F 2 around F 1 by an angle y1 on the plane passing through F 1 , F 2 and F 3 . Let T 1 be the unit tangent vector along the line F 02 F 1 . Now we derive the tangent vector D1 as follows: 9 F 1 Þ2 = m1 ¼ 2ðFðF22F ; U ¼ F þ m T ; 1 1 1 1 1 ÞT 1 (4.7) F 1 þ2U 1 ; D1 ¼ 3ðV 1 F 1 Þ; ; V1 ¼ 3
(4.3)
Our experiments have shown that the use of distancebased approximated derivatives corresponding to a given control polygon provide visually pleasing results. Fig. 2(a) is the demonstration of this derivative scheme for an ‘‘S’’-shaped control polygon. For further details, the reader is referred to [12]. 4.2. Exact derivatives For a higher continuity than C 1 , more complex constraints are required. For example, for a C 2 rational cubic spline, the constraints are ð2Þ þ Pð2Þ ðt i Þ ¼ P ðti Þ;
i ¼ 2; . . . ; n 1,
(4.4)
(a)
(b)
(c)
Fig. 3. Demonstration of end derivatives using exact derivatives (C 2 continuity). (a) Supposed, (b) distance based, (c) reasonable.
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
0
10
(a)
20
30
40
10
7.5 5 2.5 0 -2.5 -5 -7.5
Curvature
7.5 5 2.5 0 -2.5 -5 -7.5
Curvature
Curvature
598
0 -5 -10
0
10
(b)
Chord Length
5
20
30
40
0
10
(c)
Chord Length
20
30
40
Chord Length
Fig. 4. Curvature plot of spline curves in Fig. 3.
F′2
F′n-1
T1 U D1 1
F2 Fn-1
V1
1 1 F1
(a)
F3
Fn-2
Tn-1 Un-1 Dn-1 W n n-1 n Fn
(b)
Fig. 5. Estimation of end tangent vectors. (a) First tangent vector D1 . (b) Last tangent vector Dn .
(4.8)
Similarly, for the tangent vector Dn at the last point F n , let yn be the angle between F n2 F n and F n1 F n . Let F 0n1 be the rotation of F n1 around F n by an angle yn on the plane passing through F n , F n1 and F n2 . Let T n be the unit tangent vector along the line F 0n1 F n . Now we derive the tangent vector Dn as follows: 9 2 n1 F n Þ mn1 ¼ 2ðFðFn1 U n1 ¼ F n þ mn1 T n ; = F n ÞT n ; (4.9) n1 ; Dn ¼ 3ðF n W n1 Þ; ; W n1 ¼ F n þ2U 3 where mn1 is determined by the condition jU n1 F n j ¼ jU n1 F n1 j.
(b)
(c)
(d)
Fig. 6. Conic splines. (a) Parabolic, (b) hyperbolic, (c) elliptical, (d) circular.
shape factor
where m1 is determined by the condition jU 1 F 1 j ¼ jU 1 F 2 j.
(a)
(4.10)
5. Conic spline and straight line Conic sections and straight line segments are the most important components of design which can be achieved through our rational cubic interpolant (2.3). Thus we can use the same interpolant for all types of curves. As mentioned above, U i is the point of intersection of the tangents at F i and F iþ1 . In case the tangents are parallel, U i can be taken as the point where the arc is desired to be divided into two pieces. For example, it may be the inflection or the middle point, etc. For conic section properties and choice of shape parameters, various conics can be used depending upon the nature of the weights [18]. Also, readers are referred to [17, p. 291–95] and [1, p. 73–96]. According to [17], the conic
k¼
ai bi , g2i
(5.1)
determines the conic; if the three weights are changed in such a way that k is not changed. Thus any two weights can be chosen arbitrarily and the conic is then determined by the third weight. It is customary to choose ai ¼ 1 ¼ bi . The C 1 conic spline is Parabolic if gi ¼ 2 (see Figs. 6(a) and 7(a)). Hyperbolic if gi 42 (see Figs. 6(b) and 7(b)). Elliptic if 1ogi o2 (see Figs. 6(c) and 7(c)). 5.1. C 2 continuity between conic and cubic segments The rational cubic interpolant (2.3) can easily be used to adjust the conic segment in the cubic spline. Cubic segments are already joined with C 2 continuity but we also need some smoothness between the conic and the cubic segments. Although C 1 continuity is enough for visually pleasing results but user may need C 2 continuity for some practical applications where high degree of smoothness is required. Let ith segment between F i and F iþ1 be conic with its control points V 2i and W 2i . From Hermite interpolation conditions in (2.7), we obtain Di ¼ Diþ1
gi þ ai 2 ðV i F i Þ, ai g þ bi ¼ i ðF iþ1 W 2i Þ. bi
ð5:2Þ
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
599
10 5
Curvature
0
Curvature
Curvature
7.5 5 2.5 0 -2.5 -5 -7.5
-5 -10
0
10
(a)
20
30
40
Chord Length
0
(b)
10
20
30
Chord Length
7.5 5 2.5 0 -2.5 -5 -7.5
40
0
10
20
(c)
30
40
0
(d)
Chord Length
10
20
30
40
Chord Length
Fig. 7. Curvature plots of conic splines in Fig. 6. (a) Parabolic, (b) hyperbolic, (c) elliptical, (d) circular.
If i41, then for C 1 continuity at F i , we impose the ð1Þ þ constraints Pð1Þ ðt i Þ ¼ P ðti Þ to find W i1 ¼ F i
bi1 Di , gi1 þ bi1
Ui
(5.3)
and for C 2 continuity at F i , we impose the constraints ð2Þ þ Pð2Þ ðt i Þ ¼ P ðti Þ to find ai1 V i1 ¼ F i1 þ Di1 , (5.4) gi1 þ ai1
Wi
where Di1 is determined by (4.5). If ion, then for C 1 continuity at F iþ1 , we impose the ð1Þ þ constraints Pð1Þ ðt iþ1 Þ ¼ P ðtiþ1 Þ to find aiþ1 Diþ1 , (5.5) V iþ1 ¼ F iþ1 þ giþ1 þ aiþ1 2
and for C continuity at F iþ1 , we impose the constraints ð2Þ þ Pð2Þ ðt iþ1 Þ ¼ P ðtiþ1 Þ to find W iþ1
biþ1 ¼ F iþ2 Diþ2 , giþ1 þ biþ1
(5.6)
where Diþ2 is determined by (4.5). For an illustration, see Figs. 10–12 and 16 where the conic segments are stitching with neighboring cubic segments by C 2 continuity.
Vi
Fi+1
N /2
/2
Fi
b r
r
e M
Fig. 8. Be´zier points of a circular arc.
5.2. Circular spline
gi ¼ 2 cos f,
Curvature
For a G 1 circular spline, see Fig. 8 and consider (5.7)
where f is the angle between F iþ1 F i and U i F i . Let T i be the unit vector along Di and U i , the point of intersection of tangent vectors at F i and F iþ1 is U i ¼ F i þ mi T i ,
(5.8)
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 0
0.5
1 1.5 2 2.5 Chord Length
3
Fig. 9. A three-point circle given in rational cubic Be´zier form with its corresponding curvature plot.
where mi is determined by the condition jU i F i j ¼ jU i F iþ1 j,
(5.9)
from which we have
5.3. Circular arc
(5.10)
This section is devoted for the construction of a circular arc. The cases, for a given radius and given center, are independently discussed.
The circular spline is shown in Fig. 6(d) with its curvature plot in 7(d). Fig. 9 shows a three point exact circle with its curvature plot.
5.3.1. A circular arc with a given radius Let r be the given radius of the circular arc such that r4ðjF iþ1 F i jÞ=2 (see Fig. 8). Then, the center of the
2
mi ¼
ðF iþ1 F i Þ . 2ðF iþ1 F i Þ T i
ARTICLE IN PRESS 600
Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
be used as a shape control parameter as demonstrated in Fig. 11.
arc M can lie anywhere on the circle centered at N ¼ ðF i þ F iþ1 Þ=2 and having radius b as follows: sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi jF iþ1 F i j2 . b ¼ r2 4
5.3.2. A circular arc with a given center Let M be the given center of the circular arc such that jF iþ1 Mj ¼ jF i Mj (see Fig. 8). Let M 0 be the rotation of M around F i by an angle y on the plane passing through F i , F iþ1 and M, where y ¼ p=2 for a clockwise rotation and y ¼ p=2 for an anti-clockwise rotation. T i ¼ ðM 0 F i Þ=jM 0 F i j is a unit tangent vector at F i . Let f be the angle between F iþ1 F i and T i . Now use (5.7) to find gi , (5.8) to find U i , (2.5) to find control points V 2i and W 2i , then follow the procedure in Section 5.1 to achieve C 1 or C 2 continuity with neighboring cubic segments. Finally use the rational cubic interpolant (2.3) for the required circular arc. Fig. 12 shows the plot of a C-type rational cubic spline with its mid-segment as circular arc. The center of this circular arc is shown as small disk, whereas given data are shown as small circles.
(5.11)
It is preferred that M should lie on the plane passing through F i , F iþ1 and U 0i , where U 0i is the intersection of F i Di and F iþ1 Diþ1 . Therefore the circular arc should lie on the side of U 0i . Let e1 be the rotation of F iþ1 around N by an angle y on the plane passing through F i , F iþ1 and U 0i , where y ¼ p=2 for a clockwise rotation and y ¼ p=2 for an anti-clockwise rotation. Now, e ¼ ðe1 NÞ=je1 Nj is a unit vector passing through N and perpendicular to F iþ1 F i . Then, M ¼ N þ be will be the center of our required circular arc. Let f ¼ ffF i MN. Next, we find gi from (5.7). Let T 0 be the rotation of F iþ1 around F i through an angle f on the plane passing through F i , F iþ1 and U 0i . From this we have T i ¼ ðT 0 F i Þ=jT 0 F i j, a unit tangent vector at F i . Now use (5.8) to find U i , (2.5) to find control points V 2i and W 2i , then follow the procedure in Section 5.1 to achieve C 1 or C 2 continuity with neighboring cubic segments. Finally use the rational cubic interpolant (2.3) for the required circular arc. A numerical example of this is given in Fig. 10. With this scheme the radius r can
5.4. Elliptic arc
Curvature
This section is devoted to the construction of an elliptic arc in three dimensions. Very complex cases are also being examined, for example when the major axis becomes much
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 0
1
2
3 4 Chord Length
5
6
Fig. 10. A rational cubic spline with its mid-curve segment as a circular arc piece with radius r ¼ 20 and the corresponding curvature plot.
1 0.8 Curvature
0.6 0.4 0.2 0 -0.2 -0.4 0
0.5
1
1.5 2 Chord Length
2.5
3
Fig. 11. A rational cubic spline with its mid-curve segment as a circular arc with radius r ¼ 15 (dashed), 18 (bold), 24 (normal) and the corresponding curvature plot.
ARTICLE IN PRESS
Curvature
Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
601
1 0.75 0.5 0.25 0 -0.25 -0.5 -0.75 1
0
4
2 3 Chord Length
5
Fig. 12. A rational cubic spline with its mid-interval as a circular arc with a given center and the corresponding curvature plot.
larger than the minor axis and the required elliptic arc consists of the highest curvature part of the ellipse. Given start point F i , the end point F iþ1 , the center M, a unit vector along major axis X, a unit vector along minor axis Y, the semi-major axis a and the semi-minor axis b (see Fig. 13). XMY is a local coordinate system in space. Let ys ¼ ffXMF i and ye ¼ ffXMF iþ1 . If necessary, we use the Newton Raphson method to compute ys and ye . If ys 4ye , we replace ys with ys 2p. Sð¼ M þ a cos yX þ b sin yYÞ is a point on the elliptic arc, where y ¼ ðys þ ye Þ=2. Let U i be the point of intersection of tangents T 0 ð¼ a sin ys X þ b cos ys YÞ and T 1 ð¼ a sin ye X þ b cos ye YÞ at F i and F iþ1 , respectively. Let R be the point of intersection of S U i and F iþ1 F i . The quadratic rational Be´zier arc (2.2) can be written in the form QðuÞ ¼
ð1 uÞ2 F i þ uð1 uÞgi U i þ u2 F iþ1 . ð1 uÞ2 þ uð1 uÞgi þ u2
LðuÞ ¼
ð1 uÞ2 F i þ u2 F iþ1 , ð1 uÞ2 þ u2
(5.13)
which is a convex combination of F i and F iþ1 giving jR F i j u2 ¼ . jR F iþ1 j 1 u2 Then u ¼ c=ð1 þ cÞ, where sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi jR F i j . c¼ jR F iþ1 j
Vi Wi
(5.14)
S
Fi b R
Fi+1
e s M
a
X
Fig. 13. Be´zier points of elliptic arc.
(5.12)
Now the line LðuÞ ¼ ½F i ; F iþ1 is obtained by setting gi ¼ 0. Therefore
Y
Ui
required elliptic arc. A four point ellipse given in rational cubic Be´zier form with its curvature plot is shown in Fig. 14. Fig. 15 shows an elliptic arc in space generated from the following data: a ¼ 20; b ¼ 1; M ¼ ð0; 0; 2Þ F i ¼ ð18:967819; 2:184863; 3:943775Þ F iþ1 ¼ ð7:476452; 1:674027; 1:144135Þ X ¼ ð0:990033; 0:099335; 2:099833Þ Y ¼ ð0:109252; 0:989038; 1:900665Þ.
(5.15)
Therefore, QðuÞ ¼ S and from (5.12), we can easily find fð1 uÞ2 ðS F i Þ þ u2 ðS F iþ1 Þg ðU i SÞ . gi ¼ uð1 uÞjU i Sj (5.16) Now we use (2.5) to find the control points V 2i and W 2i and the rational cubic interpolant (2.3) to fix the
5.5. Intermediate point interpolation Here, we need to insert a point C between F i and F iþ1 while preserving some reasonable continuity (C 1 or C 2 ) at F i and F iþ1 . For ai ¼ 1 ¼ bi , consider Ui ¼
fð1 uÞ2 þ uð1 uÞgi þ u2 gC ð1 uÞ2 F i u2 F iþ1 ; uð1 uÞgi ð5:17Þ
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
Curvature
602
3 2 1 0 -1 -2 0
2
4
6 8 10 Chord Length
12
14
Fig. 14. A four-point ellipse given in rational cubic Be´zier form with its corresponding curvature plot.
(3) We could use the intermediate point interpolation scheme by inserting a point C on line joining F i and F iþ1 . (4) We could set gi ¼ ai þ bi and then find the control points V 1i and W 1i from (2.4).
0
4 3 2
10
20 1 0 -1 -2
Fig. 15. An elliptic arc in space.
where u¼
jF i Cj . jF i Cj þ jF iþ1 Cj
(5.18)
Next, we use (2.5) to find the control points V 2i and W 2i , then follow the procedure in Section 5.1 to achieve C 1 or C 2 continuity with neighboring cubic segments. Finally, we use the rational cubic interpolant (2.3) for the required result. Fig. 16(a) shows an intermediate point interpolation in the middle segment where the curve is forced to pass through three different small disks. The parameter u can also be used as a shape control parameter within the range 0ouo1. For different values of u, we can construct a family of curves interpolating the point C (small disk) as shown in Fig. 16(b). 5.6. Straight line segment To define a straight line segment using the rational cubic interpolant (2.3), we may use one of the following four methods: (1) We could set gi ¼ 0. (2) We could replace U i with F i or F iþ1 and then use (2.5) to find control points V 1i and W 1i .
6. Examples Data taken from times new roman character ‘‘S’’ have been interpolated using the default rational cubic spline as shown in Fig. 17(a). This does not produce the desired shape. Point and interval tension parameters are changed to achieve visually pleasing shape for font ‘‘S’’ in Fig. 17(b). Fig. 18 illustrates the design of a rational cubic spline used to generate a surface of revolution (shown in Fig. 19) that represents a cup, a lamp, a bowling pin, and a vase. Figs. 18(a, c, e, g) are the default shapes with exact derivatives and use default values of the shape parameters, i.e. ai ¼ 1 ¼ bi and gi ¼ 2. Figs. 18(b, d, f) also use exact derivatives, whereas Fig. 18(h) is plotted with distance-based approximated derivatives. To make these figures well shaped and pleasing, either we change the default shape control parameters for some segments or insert some conic or straight line segments. The data for these figures are as follows:
In Fig. 18(b), the data for the cup is fð2; 0Þ; ð25; 0Þ; ð25; 1Þ; ð2; 5Þ; ð2; 40Þ; ð10; 50Þ; ð30; 60Þ; ð38; 90Þ; ð40; 110Þg; g1 ¼ 100, g3 ¼ 10 and g4 ¼ 100. The second segment is a circular arc with radius 0.501. In Fig. 18(d), the data for the lamp is fð28; 4Þ; ð22; 4Þ; ð7; 19Þ; ð7; 30Þ; ð14; 45Þ; ð24; 45Þ; ð30; 67Þ; ð20; 85Þg; g1 ¼ 100, g3 ¼ 100, g5 ¼ 100, g6 ¼ 0:1 and g7 ¼ 100. The second segment is a circular arc with radius 15.
ARTICLE IN PRESS
Curvature
Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
603
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 0
1
2
3
4
5
6
Chord Length
Curvature
(a)
1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 0
1
2
3
4
5
6
Chord Length
(b)
Fig. 16. Intermediate point interpolation and the corresponding curvature plots. (a) u is calculated, (b) u ¼ 0:2 (normal), 0.3 (dashed), 0.257 calculated (bold).
ð6; 7Þ; ð0; 7Þg; g1 ¼ 200, g7 ¼ 0:01, gn1 ¼ 100. The fifth segment is a circular arc.
7. Conclusion
(a)
(b)
Fig. 17. The times new roman character ‘‘S’’ represented using rational cubic spline interpolation. (a) The default curve. (b) Using interval and point tension shape control.
In Fig. 18(f), the data for the bowling pin is fð0; 96Þ; ð7:5; 90Þ; ð7; 82Þ; ð6; 69Þ; ð12; 60Þ; ð20; 45Þ; ð20; 20Þ; ð12; 2Þ; ð5; 0Þ; ð0; 0Þg. The first segment is a circular arc with radius 8, the penultimate segment is a conic and the last segment is a straight line. In Fig. 18(h), the data for the vase is fð0; 0Þ; ð12; 0Þ; ð22; 3Þ; ð23; 42Þ; ð16; 88Þ; ð12; 87Þ; ð12:5; 80Þ; ð18; 18:5Þ; ð14:5; 8:5Þ;
In this paper, we have described an interval controlled rational cubic interpolation scheme. The scheme offers a number of possible ways in which the shape of the corresponding curves may be altered by the users. It is therefore felt that such a scheme could be a useful addition to an interactive design package, with the user having enough control over the curve segments. The provision of the shape parameters, in the description of the piecewise rational functions, provides freedom to modify the shape in desired regions in a stable manner. The rational spline scheme is extended for parametric curves and is capable of designing plane as well as space curves. It is an interpolatory rational spline scheme enjoying all the ideal geometric properties. It has features to produce all types of conic curves in such a way that the whole design curve may be produced as a circular, elliptic, parabolic, or a hyperbolic spline curve. In addition, the desired conic pieces may also be fitted within the rational cubic spline. Overall smoothness of the rational cubic spline is C 2 , whereas the conics are stitched either with C 1 continuity for visually pleasing results or with C 2 continuity for high degree of smoothness. The curve scheme is extendable to surfaces of revolution and swept surfaces.
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
604
(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
Fig. 18. Rational cubic spline: left—default, right—well-shaped using the shape control parameters with some conic and straight line segments.
Fig. 19. Shaded rendition of well-shaped outlines from Fig. 18: left—with wire frame, right—without wire frame.
ARTICLE IN PRESS Z. Habib et al. / Computers & Graphics 29 (2005) 594–605
Acknowledgements The authors owe thanks to referees for their valuable comments and suggestions which have helped to improve the presentation of the paper greatly. This work is supported by Japan Society for the Promotion of Science (JSPS/FF1/315-P04034).
[9]
[10]
[11]
References [12] [1] Farin G. NURB curves and surfaces. A K Peters; 1995. [2] Sarfraz M. Curve fitting for large data using rational cubic splines. International Journal of Computers and Their ‘ Applications 2003;10 (3) 233–46. [3] Sarfraz M, Khan M. Automatic outline capture of arabic fonts. International Journal of Information Sciences 2002;140(3–4):269–81. [4] Sarfraz M, Razzak M. An algorithm for automatic capturing of font outlines. International Journal of Computers and Graphics 2002;26(5):795–804. [5] Sarfraz M, Raza A. Soft computing and industry: recent applications. Berlin: Springer; 2002 [Chapter Visualization of data using genetic algorithm, p. 535–44, ISBN: 1-85233539-4]. [6] Sarfraz M. Optimal curve fitting to digital data. International Journal of WSCG 2003;11(1):128–35. [7] Gregory JA, Sarfraz M. A rational spline with tension. Computer Aided Geometric Design 1990;7:1–13. [8] Sarfraz M, Hussain M, Habib Z. Local convexity preserving rational cubic spline curves. The proceedings of IEEE international conference on information visualization-IV’97-UK, USA: IEEE Computer Society Press;
[13]
[14] [15]
[16]
[17] [18]
605
1997, p. 211–8, http://csdl.computer.org/comp/proceedings/ iv/1997/8076/00/80760211abs.htm. Gregory JA, Sarfraz M, Yuen PK. Interactive curve design using c2 rational splines. Computers and Graphics 1994;18(2):153–9. Sarfraz M, Habib Z. Rational cubic and conic representation: a practical approach. IIUM Engineering Journal, Malaysia 2000;1(2):7–15. Jamaludin MA, Said HB, Majid AA. Shape control of parametric cubic curves, The proceedings of CAD/ Graphics’95, China, 1995, p. 128–33, SPIE proceedings series, vol. 2644. Sarfraz M, Habib Z, Hussain M. Piecewise interpolation for designing of parametric curves. The proceedings of IEEE international conference on information visualization-IV’98-UK, USA: IEEE Computer Society Press; 1998, p. 307–13, http://csdl.computer.org/dl/proceedings/ iv/1998/8509/00/85090307.pdf. Meek DS, Ong B, Walton DJ. A constrained guided G1 continuous spline curve. Computer Aided Design 2003;35: 591–9. Hoschek J. Circular splines. Computer Aided Design 1992;24:611–8. Wang G-J, Wang G-Z. The rational cubic Be´zier representation of conics. Computer Aided Geometric Design 1992; 9: 447–55. Kouh JS, Chau SW. Computer-aided geometric design and panel generation for hull forms based on rational cubic Be´zier curves. Computer Aided Geometric Design 1993; 10:537–49. Piegl L, Tiller W. The NURBS book. Berlin: Springer; 1995. Sarfraz M. Curves and surfaces for CAD using C 2 rational cubic splines. Engineering with Computers 1995;11(2): 94–102.