[ Pobierz całość w formacie PDF ]
.If the start and end directions of the segment arevery different, the entire segment cannot be a straight line, so, in order to minimize itsoverall second derivative, the segment will end up consisting of two or three parts, eachclose to a straight line, with short, highly-curved corners connecting them (Figure 5.4). 5.1 The Cubic Spline Curve 155Such a geometry has a small overall second derivative.This knowledge is useful whendesigning curves, which is why the nonuniform cubic spline should not be dismissed asimpractical.It may be the best method for certain curves.Figure 5.4: Curves with Small Overall Second Derivative.Example: The four points of Section 5.1.1 are used in this example.They areP1 =(0, 0), P2 =(1, 0), P3 =(1, 1), and P4 =(0, 1).We also select the same initialand final directions Pt =(1, -1) and Pt =(-1, -1).We decide to use tk = 2 for each1 4of the three spline segments to illustrate how large tk values create a curve very differentfrom the one of Section 5.1.1.Equation (5.23) becomes# #(1, -1)3# # [t2(P3 - P2) +t2(P2 - P1)]2t2 2(t1 + t2) t1 0 Pt t1t2 12# #=.30 t3 2(t2 + t3) t2 # Pt #[t2(P4 - P3) +t2(P3 - P2)]33t2t3 2(-1, -1)For t1 = t2 = t3 = 2, this yields Pt =(1/6, 1/2) and Pt =(-1/6, 1/2).Equation (5.24)2 3is now written and solved three times:# # # #a 2/t3 -2/t3 1/t2 1/t2 # # (0, 0)1 1 1 1b # ## # # -3/t2 3/t2 -2/t1 -1/t1 (1, 0) #1 1Segment 1 =.# # # # # #c 0 0 1 0 (1, -1)d 1 0 0 0 (1/6, 1/2)# # # #a 2/t3 -2/t3 1/t2 1/t2 # # (1, 0)2 2 2 2b # ## # # -3/t2 3/t2 -2/t2 -1/t2 (1, 1) #2 2Segment 2 =.# # # # # #c 0 0 1 0 (1/6, 1/2)d 1 0 0 0 (-1/6, 1/2)# # # #a 2/t3 -2/t3 1/t2 1/t2 # # (1, 1)3 3 3 3b # ## # # -3/t2 3/t2 -2/t3 -1/t3 (0, 1) #3 3Segment 3 =.# # # # # #c 0 0 1 0 (-1/6, 1/2)d 1 0 0 0 (-1, -1)This yields the coefficients for the three spline segments:P1(t) =(1/24, -1/8)t3 +(-1/3, 3/4)t2 +(1, -1)t,P2(t) =(0, 0)t3 +(-1/12, 0)t2 +(1/6, 1/2)t +(1, 0),P3(t) =-(1/24, 1/8)t3 +(-1/12, 0)t2 +(-1/6, 1/2)t +(1, 1). 156 5.Spline InterpolationThe result is shown in Figure 5.5.It should be compared with the uniform curve ofFigure 5.2 that s based on the same four points.(Recall that t varies from0 to 2 in eachof the segments above.)1.251P2P10.5P1 P20.2 0.61-0.25(*Nonuniformcubicsplineexample*)C1:=ParametricPlot[{1/24,-1/8}t^3+{-1/3,3/4}t^2+{1,-1}t,{t,0,2},PlotRange->All,Compiled->False,DisplayFunction->Identity];C2:=ParametricPlot[{-1/12,0}t^2+{1/6,1/2}t+{1,0},{t,0,2},PlotRange->All,Compiled->False,DisplayFunction->Identity];C3:=ParametricPlot[-{1/24,1/8}t^3+{-1/12,0}t^2+{-1/6,1/2}t+{1,1},{t,0,2},PlotRange->All,Compiled->False,DisplayFunction->Identity];Show[C1,C2,C3,PlotRange->All,AspectRatio->Automatic,DisplayFunction->$DisplayFunction,DefaultFont->{"cmr10",10}];Figure 5.5: A Nonuniform Cubic Spline Example.5.2 The Quadratic SplineThe cubic spline curve is useful in certain practical applications, which raises the questionof splines of different degrees based on the same concepts.It turns out that splinesof degrees higher than 3 are useful only for special applications because they are morecomputationally intensive and tend to have many undesirable inflection points (i.e., theytend to wiggle excessively).Splines of degree 1 are, of course, just straight segmentsconnected to form a polyline, but quadratic (degree-2) splines can be useful in someapplications.Such a spline is easy to derive and to compute.Each spline segmentis a quadratic polynomial, i.e., a parabolic arc, so it results in fewer oscillations in thecurve.On the other hand, quadratic spline segments connect with at most C1 continuitybecause their second derivative is a constant.Thus, a quadratic spline curve may notbe as tight as a cubic spline that passes through the same points.The quadratic spline curve is derived in this section based on the variant Hermitesegment of Section 4.7.Each segment Pi(t) is therefore a quadratic polynomial defined 5.2 The Quadratic Spline 157by its two endpoints Pi and Pi+1 and by its start tangent vector Pt.Equation (4.33)ishows that the end tangent of such a segment is Pt(1) = 2(Pi+1 - Pi) - Pt.The firsti itwo spline segments areP1(t) =(P2 - P1 - Pt)t2 + Pt t + P1,1 1P2(t) =(P3 - P2 - Pt)t2 + Pt t + P2.2 2At their joint point P2 they have the tangent vectors Pt(1) = 2(P2 - P1) - Pt and1 1Pt(0) = Pt.In order to achieve C1 continuity we have to have the boundary condition2 2Pt(1) = Pt(0) or 2(P2 - P1) - Pt = Pt.This equation can be written Pt + Pt =1 2 1 2 1 22(P2 -P1), and when duplicated n-1 times, for the points P1 through Pn-1, the resultis# # ## Pt # #P2 - P1 #1 1 0 0 0 01#### 0 1 1 0 0 0 ## 2 # # P3 - P2 ##=# ## Pt # #n-1.(5.25).#.##.# 2 # #.#.# #.#.#0 0 0 0 1 1Pt Pn - Pn-1nnAs with the cubic spline, there are more unknowns than equations (n unknowns andn - 1 equations), and the standard technique is to ask the user to provide a value forone of the unknown tangent vectors, normally Pt.1Example: We select the four points of Section 5.1.1, namely P1 = (0, 0), P2 =(1, 0), P3 =(1, 1), and P4 =(0, 1).We also select the same start tangent Pt =(1, -1).1Equation (5.25) becomes# ## # # # # #Pt11 1 0 0 P2 - P1 (2, 0)Pt# #2# # # # #0 1 1 0 =2 P3 - P2 # = (0, 2) ,# #Pt30 0 1 1 P4 - P3 (-2, 0)Pt4with solutions Pt =(1, 1), Pt =(-1, 1), and Pt =(-1, -1).The three spline segments2 3 4becomeP1(t) =(P2 - P1 - Pt)t2 + Pt t + P1 =(t, t2 - t),1 1P2(t) =(P3 - P2 - Pt)t2 + Pt t + P2 =(-t2 + t +1, t),2 2P3(t) =(P4 - P3 - Pt)t2 + Pt t + P3 =(-t +1, -t2 + t +1).3 3Their tangent vectors are Pt(t) =(1, 2t-1), Pt(t) =(-2t+1, 1), and Pt(t) =(-1, -2t+1 2 31).It is easy to see that Pt(1) = Pt(0) = (1, 1) and Pt(1) = Pt(0) = (-1, 1).Also,1 2 2 3the end tangent of the entire curve is Pt(1) = (-1, -1), the same as for the cubic case.3The complete spline curve is shown in Figure 5.6. 158 5.Spline Interpolationy1.21 P4P30.80.60.40.2P2xP10.2 0.4 0.6 0.8 1 1.2-0 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • katek.htw.pl






  • Formularz

    POst

    Post*

    **Add some explanations if needed