function F = movingframe(r,t,a,b,x0,x1,y0,y1,z0,z1) % movingframe plots the curve r(t) for t in [a,b] and, one at a time, % the frame T,N,B at 100 equally spaced times in the interval [a,b]. The % axis for each frame is the same, with x-limits x0,x1, y-limits y0,y1 and % z-limits z0,z1. T is blue, N is green and B is red. % Make the components of the parametrized curve functions rx = inline(vectorize(r(1))); ry = inline(vectorize(r(2))); rz = inline(vectorize(r(3))); % Calculate the derivative of the parametrized curve rp = diff(r); % Calculate the step size c = (b-a)/100; % Make the vector of points at which the curve will be plotted. S = a:0.01:b; % Calculate the unit tangent vector T = simplify(diff(r)/sqrt(diff(r)*transpose(diff(r)))); % Calculate the binormal B1 = cross(T,diff(T)); B = simplify(B1/sqrt(B1*transpose(B1))); % Calculate the unit normal N = simplify(cross(B,T)); % Make the components of the frame vectors functions Tx = inline(vectorize(T(1))); Ty = inline(vectorize(T(2))); Tz = inline(vectorize(T(3))); Nx = inline(vectorize(N(1))); Ny = inline(vectorize(N(2))); Nz = inline(vectorize(N(3))); Bx = inline(vectorize(B(1))); By = inline(vectorize(B(2))); Bz = inline(vectorize(B(3))); for k = 1:101 clf plot3(rx(S),ry(S),rz(S),'k') hold on quiver3(rx(a+c*(k-1)),ry(a+c*(k-1)),rz(a+c*(k-1)),Tx(a+c*(k-1)),Ty(a+c*(k-1)),... Tz(a+c*(k-1)),'LineWidth',2','color','b'); quiver3(rx(a+c*(k-1)),ry(a+c*(k-1)),rz(a+c*(k-1)),Nx(a+c*(k-1)),... Ny(a+c*(k-1)),Nz(a+c*(k-1)),'LineWidth',2','color','g'); quiver3(rx(a+c*(k-1)),ry(a+c*(k-1)),rz(a+c*(k-1)),Bx(a+c*(k-1)),... By(a+c*(k-1)),Bz(a+c*(k-1)),'LineWidth',2','color','r'); axis([x0 x1 y0 y1 z0 z1]) axis square F(k) = getframe; end