**Animated gifs from Maple, using
rotation matrices for the euler angles.**

(Note: The viewing direction is different in the two animations.)

a) Which Euler angles are changing in the lefthand animation?

b) Which Euler angles are changing in the righthand animation?

Show the effect of a rotation matrix on a vector as a function of time. In particular, implement the euler angle rotations and animate them.

Viewing is done along a polar (Pol) and azimuthal (Az) angle.

Initial angles theta, phi, and psi are specified, and rotation rates for all 3.

The calculation starts from body x3,y3,z3 components, and works backward to the space xyz coordinates. When x,y,z are known for each body axis, a projection is done into the viewing direction, and an animation is made.

Forward rotation thru angle a gives xnew = xold cos(a) + yold sin(a), etc.

MAPLE COMMANDS ARE IN BOLDFACE.

**restart;with(plots):
with(linalg): **

Rotation matrix m1 is forward rotation thru angle x.

x'= m1 * x .

Ditto for m2 and m3

**m1:=matrix([[1,0,0],[0,cos(x),sin(x)],[0,-sin(x),cos(x)]]);
m2:=matrix([[cos(x),0,sin(x)],[0,1,0],[-sin(x),0,cos(x)]]);
m3:=matrix([[cos(x),sin(x),0],[-sin(x),cos(x),0],[0,0,1]]);**

We start with body axes in their fully rotated x3,y3,z3 system. (The body x axis is (1,0,0) in this system.) To get to components of the rotated body axes in the original space x,y,z system we must do a reverse rotation thru -psi, then reverse thru -theta, then reverse thru -phi. This will lead us to the xyz components of the body's axes after the body has been rotated in space

**r1:=subs(x=-phi,evalm(m3));
r2:=subs(x=-theta,evalm(m1));
r3:=subs(x=-psi,evalm(m3));
r123:=evalm(r1 &* r2 &* r3);**

To represent the body x-axis, we will later set (f1, f2, ,f3) to (1,0,0), then to (0,1,0) for body y axis, etc.

v represents the x,y,z components of (f1,f2,f3) after it has been rotated through the three Euler angles.

**v1:=matrix([[f1],[f2],[f3]]);
v:=evalm(r123 &* v1);**

But we will be viewing the rotated vector v along a particular direction in space.

The pL vector below gives the projection of a vector in x,y,z in the plane perpendicular to a viewing direction specified by polar and azimuthal angles Pol, and Az.

This projection is necessary to get relatively rapid animation. A full 3d animation in Maple is very time consuming.

p0 represents the point at the origin of coordinates.

**p0:=[0,0];
pL:=[-a*sin(Az)+b*cos(Az),-cos(Pol)*(a*cos(Az)+b*sin(Az))+c*sin(Pol)];**

Viewing angles are set up here, polar and azimuthal .

**viewsubs:={Pol=2*Pi/10,Az=1*Pi/4};**

Now set up the view and plots of the x,y,z axes

**ax:=subs(a=1,b=0,c=0,viewsubs,pL):
ay:=subs(a=0,b=1,c=0,viewsubs,pL):
az:=subs(a=0,b=0,c=1,viewsubs,pL):
zax:=plot([p0,az],color=black,axes=NONE,scaling=constrained): xax:=plot([p0,ax],color=black,axes=NONE,scaling=constrained):**

Now set up the view of lines which have been rotated

**p1:=subs(a=v[1,1],b=v[2,1],c=v[3,1],pL):
p:=subs(viewsubs,p1):
px:=subs(f1=1,f2=0,f3=0,p):
py:=subs(f1=0,f2=1,f3=0,p):
pz:=subs(f1=0,f2=0,f3=1,p):**

**Nframes:=35;
Psidot:=2*Pi/18; Thetadot:=0;Phidot:=2*Pi/36;
Theta0:=Pi/12;Phi0:=0;Psi0:=0;**

**for i from 0 to Nframes do
sbs:={theta=Theta0+i*Thetadot,phi=Phi0+i*Phidot,psi=Psi0+i*Psidot}:
gx.(i):=plot(subs(sbs,[p0,px]),color=blue,scaling=constrained,thickness=3,axes=NONE):
gy.(i):=plot(subs(sbs,[p0,py]),color=red,scaling=constrained,thickness=3,axes=NONE):
gz.(i):=plot(subs(sbs,[p0,pz]),thickness=3,color=black,scaling=constrained,axes=NONE):
m.(i):=display({gx.(i),gy.(i),gz.(i),xax,yax,zax}): od: **

**display([m.(0..Nframes)],insequence=true);**

Download EulerAng..mws [Use 'Save File')