InputMode:=Word "A Bezier curve can be defined by two parametric equations:" eq11:=[x=a0+a1*t+a2*t^2+a3*t^3,y=b0+b1*t+b2*t^2+b3*t^3] "A Bezier curve can also be defined by four control points." [[x0,y0],[x1,y1],[x2,y2],[x3,y3]] "x=x0 xnd y=y0 when t=0 so" eq12:=SUBST(eq11,[x,y,t],[x0,y0,0]) "x=x3 and y=y3 when t=1 so" eq13:=SUBST(eq11,[x,y,t],[x3,y3,1]) "The other two control points require the derivative of the curve which is:" eq14:=[dx,dy]=DIF(RHS(eq11),t) "dx=3(x1-x0) and dy=3(y1-y0) when t=0 so" eq15:=SUBST(eq14,[dx,dy,t],[3*(x1-x0),3*(y1-y0),0]) "dx=3(x3-x2) and dy=3(y3-y2) when t=1 so" eq16:=SUBST(eq14,[dx,dy,t],[3*(x3-x2),3*(y3-y2),1]) "Solve for a0, a1, a2, a3, b0, b1, b2, b3 using equations 1.2, 1.3, 1.5, and ~ 1.6." eq17:=SOLVE((SOLVE(APPEND(eq12,eq13),[a0,a1,a2,a3,b0,b1,b2,b3])) SUB 1 AND eq~ 15 AND eq16,[a0,a1,a2,a3,b0,b1,b2,b3]) "The example will use these four control points:" eq18:=[[x0,y0],[x1,y1],[x2,y2],[x3,y3]]=[[6,8],[1,10],[7,3],[4,4]] "Substitute these values in equation 1.7." eq19:=SOLVE(eq18 AND eq17,[a0,a1,a2,a3,b0,b1,b2,b3,x0,x1,x2,x3,y1,y0,y2,y3]) "Substitute these values in equation 1.1 to find the Bezier curve." eq110:=SOLVE((SOLVE(eq11,[x,y])) SUB 1 AND eq19,[x,y,a0,a1,a2,a3,b0,b1,b2,b3,~ x0,x1,x2,x3,y0,y1,y2,y3]) eq111:=[LHS(eq110),LHS(RHS(eq110))] "Here is the example Bezier curve and the control points:" "To show the control points we want a line such that x=x0 and y=y0 when t=0 a~ nd x=x1 y=y1 when t=1." eq112:=(SOLVE(VECTOR(SUBST([x=m1*t+b1,y=m2*t+b2],[x,y,t],v),v,[[x,y,t],[x0,y0~ ,0],[x1,y1,1]]),[x,y,b1,b2,m1,m2])) SUB 1 "We want another line such that x=x3 and y=y3 when t=0 and x=x2 and y=y2 when~ t=1." eq113:=(SOLVE(VECTOR(SUBST([x=m1*t+b1,y=m2*t+b2],[x,y,t],v),v,[[x,y,t],[x3,y3~ ,0],[x2,y2,1]]),[x,y,b1,b2,m1,m2])) SUB 1 "Plot this with t=0 to t=1." SUBST([[RHS(LHS(eq112)),RHS(LHS(RHS(eq112)))],[RHS(LHS(eq113)),RHS(LHS(RHS(eq~ 113)))],RHS(eq111)],APPEND([[x0,y0],[x1,y1],[x2,y2],[x3,y3]]),APPEND([[6,8],[~ 1,10],[7,3],[4,4]])) "The length of a curve is s, which is an integral." ds=SQRT(dx^2+dy^2) eq21a:=ds=SQRT(dx^2+dy^2) s='INT(ds,t) "The length s is from t=0 to t=1." eq21:=s=''INT(SQRT(dx^2+dy^2),t,0,1) "Substitute the values for the Bezier curve from equation 1.4." eq22a:=[LHS(eq14),RHS(eq14)] eq22:=SUBST(eq21,LHS(eq22a),RHS(eq22a)) "Substitute the example values of a1, a2, a3, b1, b2, b3 from equation 1.9." eq23a:=[a0,a1,a2,a3,b0,b1,b2,b3,x0,x1,x2,x3,y0,y1,y2,y3] eq23:=SUBST(eq22,eq23a,(SOLUTIONS(eq19,eq23a)) SUB 1) "Factor the polynomial in the integral." eq25a:=dx^2+dy^2 eq25b:=SUBST(eq25a,LHS(eq22a),RHS(eq22a)) eq25c:=SUBST(eq25b,eq23a,(SOLUTIONS(eq19,eq23a)) SUB 1) eq25:=VECTOR(x SUB 1,x,FACTORS(eq25c,Complex,t)) "This integral is an elliptic integral which is in tables of elliptic integra~ ls on a web site: http://www.getnet.net/~cherry/derive/index.html" "The type of elliptic integral that is to be evaluated:" [IA(m):=,IHAT(m):=] kk:=SQRT(eq25 SUB 5) eq31:=kk*IA(e1+e2+e3+e4) [h=4,n=4,a=c,b=[-1,-1,-1,-1],x=1,y=0] "Since h = 4 and n = 4 use the table: http://www.getnet.net/~cherry/derive/IH~ 4N4N.txt" "For b = [-1, -1, -1, -1] IA(m)=IHAT(m)." LOAD("c2001.mth") ei:= "This is the function that generates the table of integrals." "For the integral IHAT(e1+e2+e3+e4) m=[1,1,1,1] and i=1." eq32:=EXPAND(RE179(1,[1,1,1,1],4,4),et) rij=ai/bi-aj/bj [aa:=-SUBST(VECTOR(eq25 SUB i,i,1,4),[t],[0]),bb:=[-1,-1,-1,-1]] AHAT(2*e1+e2+e3+e4)=APPROX(AHAT_xy([2,1,1,1],4,4,aa,bb,1,0),24) AHAT(e1+e2+e3+e4)=APPROX(AHAT_xy([1,1,1,1],4,4,aa,bb,1,0),24) AHAT(e2+e3+e4)=APPROX(AHAT_xy([0,1,1,1],4,4,aa,bb,1,0),24) rr(i,j,a,b):=a SUB i/b SUB i-a SUB j/b SUB j eq33:=SUBST(eq32,[r12,r13,r14,AHAT(2*e1+e2+e3+e4),AHAT(e1+e2+e3+e4),AHAT(e2+e~ 3+e4)],[rr(1,2,aa,bb),rr(1,3,aa,bb),rr(1,4,aa,bb),APPROX(AHAT_xy([2,1,1,1],4,~ 4,aa,bb,1,0),24),APPROX(AHAT_xy([1,1,1,1],4,4,aa,bb,1,0),24),APPROX(AHAT_xy([~ 0,1,1,1],4,4,aa,bb,1,0),24)]) LOAD("c2001a.mth") LOAD("carlson.mth") "Substitute the functions that generate the basic integrals." eq310:=APPROX(ISHAT(eq33,aa,bb,1,0),24) eq311:=kk*eq310 "This is the length of the example Bezier curve." APPROX(s=eq311,24)