Auxiliary Function Definition (execute -- but do not change!)

Execute these commands once. DO NOT MAKE ANY CHANGES!

> animatemotion3d := proc( x, y, z, p )

> local nframe, npoint, _e, _scene, t, lo, hi,

> _R, _V, _A, _T, _N, _B, _speed, _aT, _aN,

> pR, plot1, anim,

> vecR, vecV, vecA, vecT, vecN, vecB;

> nframe := 10;

> _scene := [ R, V, A ];

> if nargs>4 then

> for _e in args[5..-1] do

> if not type(_e,symbol=anything) then

> error( `invalid optional parameter, symbol=numeric expected, received `, _e )

> end if;

> if lhs(_e)='scene' then

> if type(rhs(_e),list(symbol))

> and nops( convert(rhs(_e),set) minus {R,V,A,T,N,B} ) = 0 then

> _scene:=rhs(_e);

> else

> error( `invalid scene, list containing one or more of R, V, A, T, N, and B expected, received`, rhs(_e) );

> end if;

> end if;

> if lhs(_e)='frames' then nframe:=rhs(_e) end if;

> end do;

> end if;

> if type(lhs(p),symbol) and type(evalf(rhs(p)),numeric..numeric) then

> t := lhs(p);

> lo, hi := op(rhs(p));

> else

> error( `invalid fourth parameter, t = lo .. hi expected, received`, p );

> end if;

> _R := unapply( [x,y,z], t );

> _V := unapply( diff([x,y,z], t ), t );

> _A := unapply( diff([x,y,z], t,t ), t );

> _speed := simplify( linalg[norm](_V(t),2) ) assuming t::real;

> _T := unapply( simplify( expand( _V(t) / _speed ) ), t );

> _aT := simplify( linalg[innerprod]( _V(t), _A(t) ) / _speed ) assuming t::real;

> _aN := simplify( linalg[norm]( linalg[crossprod](_V(t),_A(t)), 2 ) / _speed ) assuming t::real;

> _N := unapply( simplify( expand( ( _A(t) - _aT*_T(t) ) / _aN ) ), t );

> _B := unapply( simplify( convert( linalg[crossprod]( _T(t), _N(t) ), list ) ), t );

> pR := spacecurve( [ x, y, z, p ], scaling=constrained );

> if has( _scene, R ) then

> vecR := _t -> plottools[arrow]( [0,0,0], _R(_t), .1, .2, .1, color=black ):

> else

> vecR := NULL;

> end if;

> if has( _scene, 'V' ) then

> vecV := _t -> plottools[arrow]( _R(_t), _R(_t)+_V(_t), .2, .4, .2, color=green ):

> else

> vecV := NULL;

> end if;

> if has( _scene, 'A' ) then

> vecA := _t -> plottools[arrow]( _R(_t), _R(_t)+_A(_t), .2, .4, .2, color=blue ):

> else

> vecA := NULL;

> end if;

> if has( _scene, 'T' ) then

> vecT := _t -> plottools[arrow]( _R(_t), _R(_t)+_T(_t), .2, .4, .2, color=orange ):

> else

> vecT := NULL;

> end if;

> if has( _scene, 'N' ) then

> vecN := _t -> plottools[arrow]( _R(_t), _R(_t)+_N(_t), .2, .4, .2, color=magenta ):

> else

> vecN := NULL;

> end if;

> if has( _scene, 'B' ) then

> vecB := _t -> plottools[arrow]( _R(_t), _R(_t)+_B(_t), .2, .4, .2, color=cyan ):

> else

> vecB := NULL;

> end if;

> plot1 := unapply( display( vecR(_t), vecV(_t), vecA(_t), vecT(_t), vecN(_t), vecB(_t) ), _t );

> anim := display( [seq(plot1(t), t=evalf(lo + (hi-lo)*[$0..nframe-1]/(nframe-1))) ], scaling=constrained, axes=framed, insequence=true ):

> display( [pR,anim] );

> end proc: