Simplify and the Rotation matrices

• To: "mathgroup" <mathgroup at yoda.ncsa.uiuc.edu>
• Subject: Simplify and the Rotation matrices
• From: "WILLIAM M. GOLDING" <golding at ccf4.nrl.navy.mil>
• Date: 21 Jan 91 12:38:00 EST

```This is in response to Paul Schatz's question concerning Simplify etc.

Paul, you need to use the trigonometry package under the algebra directory.
This package defines functions like TrigExpand and TrigReduce, which seem to
work well with the rotation matrices.

Here is a sample session.

Mathematica (MS-DOS 386/7) 1.2 (September 27, 1989) [With pre-loaded data]
by S. Wolfram, D. Grayson, R. Maeder, H. Cejtin,
S. Omohundro, D. Ballman and J. Keiper
with I. Rivin, D. Withoff and T. Sherlock

(*
First load the trigonometry package which is in the algebra directory
*)

In[1]:= <<"algebra\\trigonom.m"

(*
Next enter the three separate rotation matrices so that they can be
multiplied to get the overall rotation matrix.  I'm using x, y and z as
the rotation angles.
*)

In[2]:= d={{Cos[x],Sin[x],0},{-Sin[x],Cos[x],0},{0,0,1}}

Out[2]= {{Cos[x], Sin[x], 0}, {-Sin[x], Cos[x], 0}, {0, 0, 1}}

In[3]:= c={{1,0,0},{0,Cos[x],Sin[x]},{0,-Sin[x],Cos[x]}}

Out[3]= {{1, 0, 0}, {0, Cos[x], Sin[x]}, {0, -Sin[x], Cos[x]}}

In[4]:= c=%/.x->y

(*
I meant to use y instead of x for the angle of the c rotation
*)

Out[4]= {{1, 0, 0}, {0, Cos[y], Sin[y]}, {0, -Sin[y], Cos[y]}}

In[5]:= b={{Cos[x],Sin[x],0},{-Sin[x],Cos[x],0},{0,0,1}}/.x->z

Out[5]= {{Cos[z], Sin[z], 0}, {-Sin[z], Cos[z], 0}, {0, 0, 1}}

(*
I'll just display the three matrices here
*)

In[6]:= b

Out[6]= {{Cos[z], Sin[z], 0}, {-Sin[z], Cos[z], 0}, {0, 0, 1}}

In[7]:= c

Out[7]= {{1, 0, 0}, {0, Cos[y], Sin[y]}, {0, -Sin[y], Cos[y]}}

In[8]:= d

Out[8]= {{Cos[x], Sin[x], 0}, {-Sin[x], Cos[x], 0}, {0, 0, 1}}

(*  or if you prefer  *)

In[9]:= MatrixForm[b]

Cos[z]   Sin[z]   0

-Sin[z]  Cos[z]   0

Out[9]//MatrixForm= 0        0        1

In[10]:= MatrixForm[c]

1        0        0

0        Cos[y]   Sin[y]

Out[10]//MatrixForm= 0        -Sin[y]  Cos[y]

In[11]:= MatrixForm[d]

Cos[x]   Sin[x]   0

-Sin[x]  Cos[x]   0

Out[11]//MatrixForm= 0        0        1

(*  Now form the complete rotation matrix,  a
by multiplying the individual matrices
*)

In[12]:= a=b.c.d

Out[12]= {{Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z],

>     Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z], Sin[y] Sin[z]},

>    {-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z],

>     Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z], Cos[z] Sin[y]},

>    {Sin[x] Sin[y], -(Cos[x] Sin[y]), Cos[y]}}

In[13]:= MatrixForm[a]   (* not much help here *)

Out[13]//MatrixForm=

Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z]

>   Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z]

>   Sin[y] Sin[z]

-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z]

>   Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z]

>   Cos[z] Sin[y]

Sin[x] Sin[y]

>   -(Cos[x] Sin[y])

>   >   Cos[y]

(* Now multiply a by a transpose.  This should give the identity matrix  *)

In[14]:= identity=a.Transpose[a]

2       2                                         2
Out[14]= {{Sin[y]  Sin[z]  + (Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z])  +

2
>      (Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z]) ,

2
>     Cos[z] Sin[y]  Sin[z] + (Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z])

>       (Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z]) +

>      (-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z])

>       (Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z]),

>     Cos[y] Sin[y] Sin[z] - Cos[x] Sin[y]

>       (Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z]) +

>      Sin[x] Sin[y] (Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z])},

2
>    {Cos[z] Sin[y]  Sin[z] + (Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z])

>       (Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z]) +

>      (-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z])

>       (Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z]),

2       2                                            2
>     Cos[z]  Sin[y]  + (-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z])  +

2
>      (Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z]) ,

>     Cos[y] Cos[z] Sin[y] + Sin[x] Sin[y]

>       (-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z]) -

>      Cos[x] Sin[y] (Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z])},

>    {Cos[y] Sin[y] Sin[z] - Cos[x] Sin[y]

>       (Cos[z] Sin[x] + Cos[x] Cos[y] Sin[z]) +

>      Sin[x] Sin[y] (Cos[x] Cos[z] - Cos[y] Sin[x] Sin[z]),

>     Cos[y] Cos[z] Sin[y] + Sin[x] Sin[y]

>       (-(Cos[y] Cos[z] Sin[x]) - Cos[x] Sin[z]) -

>      Cos[x] Sin[y] (Cos[x] Cos[y] Cos[z] - Sin[x] Sin[z]),

2         2       2         2       2
>     Cos[y]  + Cos[x]  Sin[y]  + Sin[x]  Sin[y] }}

(*  It's kind of hard to see that this last result is the identity matrix,
so let's simplify it some *)

In[15]:= TrigExpand[identity]

Cos[2 x - 2 y - 2 z]   Cos[-2 x + 2 y - 2 z]
Out[15]= {{1 - -------------------- + --------------------- -
32                     32

Cos[2 x - 2 y + 2 z]   Cos[-2 x + 2 y + 2 z]
>      -------------------- + ---------------------, 0, 0},
32                     32

Cos[2 x - 2 z]   Cos[-2 x + 2 z]
>    {0, 1 + -------------- - ---------------, 0},
8                 8

Cos[2 x - 2 y]   Cos[-2 x + 2 y]
>    {0, 0, 1 + -------------- - ---------------}}
8                 8

In[16]:= TrigReduce[%]

Out[16]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

In[17]:= MatrixForm[%]

1  0  0

0  1  0

Out[17]//MatrixForm= 0  0  1

(*  And this does seem to be the right answer  *)

Hope this helps,

Mike Golding

```

• Prev by Date: Lost and Found: @m'ma conference
• Next by Date: Mathematica Conference Impressions
• Previous by thread: Lost and Found: @m'ma conference
• Next by thread: Mathematica Conference Impressions