(*^
::[ Information =
"This is a Mathematica Notebook file. It contains ASCII text, and can be
transferred by email, ftp, or other text-file transfer utility. It should
be read or edited using a copy of Mathematica or MathReader. If you
received this as email, use your mail application or copy/paste to save
everything from the line containing (*^ down to the line containing ^*)
into a plain text file. On some systems you may have to give the file a
name ending with ".ma" to allow Mathematica to recognize it as a Notebook.
The line below identifies what version of Mathematica created this file,
but it can be opened using any other version as well.";
FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2";
MacintoshStandardFontEncoding;
fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times";
fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times";
fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times";
fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times";
fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times";
fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times";
fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 14, "Times";
fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier";
fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier";
fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier";
fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, groupLikeGraphics, M7, l34, w405, h197, 12, "Courier";
fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva";
fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = leftheader, inactive, L2, 12, "Times";
fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times";
fontset = leftfooter, inactive, L2, 12, "Times";
fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
paletteColors = 128; currentKernel;
]
:[font = section; inactive; Cclosed; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup]
Exercise 1: Euler rotations
;[s]
1:0,1;28,-1;
2:0,19,14,Times,1,18,0,0,0;1,19,14,Times,1,18,65535,0,0;
:[font = input; preserveAspect]
Clear["Global`*"]
:[font = text; inactive; preserveAspect]
Let's start by creating a 3-D rotation matrix, ry[th_], that generates rotations about the y-axis.
:[font = input; preserveAspect]
ry[th_]={{Cos[th],0,Sin[th]},{0,1,0},{-Sin[th],0,Cos[th]}};
:[font = text; inactive; preserveAspect]
Verify that this is a unitary transformation, that is: ry[th].Transpose[ry[th] ] = unit matrix
;[s]
4:0,0;55,1;81,0;94,1;95,-1;
2:2,16,12,Times,0,14,0,0,0;2,13,10,Courier,1,12,0,0,0;
:[font = input; preserveAspect]
ry[th].Transpose[ry[th] ] //Simplify //MatrixForm
:[font = text; inactive; preserveAspect]
Similarly, let's create a 3-D rotation matrix, rz[th_], that generates rotations about the z-axis.
:[font = input; preserveAspect]
rz[th_]={{Cos[th],Sin[th],0},{-Sin[th],Cos[th],0},{0,0,1}};
:[font = text; inactive; preserveAspect]
Verify that this is a unitary transformation, that is:rz[th].Transpose[rz[th] ] = unit matrix
;[s]
3:0,0;54,1;80,0;94,-1;
2:2,16,12,Times,0,14,0,0,0;1,13,10,Courier,1,12,0,0,0;
:[font = input; preserveAspect]
rz[th].Transpose[rz[th] ] //Simplify
:[font = text; inactive; preserveAspect]
Eulers matrix can be define as:
:[font = input; preserveAspect]
euler=ry[th1].rz[th2].ry[th3];
:[font = text; inactive; preserveAspect]
Here is a rule that generates random angles between [0,2 Pi].
:[font = input; preserveAspect]
rule=
{th1-> 2 Pi Random[]
,th2-> 2 Pi Random[]
,th3-> 2 Pi Random[]
};
:[font = text; inactive; preserveAspect]
We can use this to generate a random Euler matrix:
:[font = input; preserveAspect]
mat= euler /.rule //N;
mat //MatrixForm
:[font = text; inactive; preserveAspect]
There is a theorem that state that the Euler matrix always has one real eigenvector
:[font = input; preserveAspect]
ev= Eigenvectors[ mat //N ] //Chop;
ev //MatrixForm
:[font = text; inactive; preserveAspect]
and at least one eigenvalue that is equal to 1.
:[font = input; preserveAspect]
Eigenvalues[ mat //N ] //Chop
:[font = text; inactive; preserveAspect; endGroup]
This implies that an Euler rotation can always be described as a simple rotation about a eigenvector with eigenvalue =1.
:[font = section; inactive; preserveAspect; cellOutline; backColorRed = 58981; backColorGreen = 58981; backColorBlue = 58981; startGroup]
Problem 2: Euler rotations
;[s]
1:0,1;27,-1;
2:0,19,14,Times,1,18,0,0,0;1,19,14,Times,1,18,65535,0,0;
:[font = subsection; inactive; Cclosed; preserveAspect; cellOutline; fontColorRed = 65535; startGroup]
Your Challenge: For a given numerical Euler matrix, find the rotation axis and angle that will generate the Euler matrix.
Bonus: Can you find a similarity transformation that converts mat into a simple rotation about the z-axis.
;[s]
2:0,0;123,1;231,-1;
2:1,16,12,Times,1,14,65535,0,0;1,16,12,Times,3,14,65535,0,0;
:[font = text; inactive; preserveAspect; fontColorRed = 65535]
I left my comments in if you want to follow my method; or you can choose your own method.
:[font = text; inactive; preserveAspect]
Let's first identify the eigenvector that is invariant under the mat operation.
:[font = text; inactive; preserveAspect]
Now, let's check that vec is normalized:
:[font = text; inactive; preserveAspect]
Now, let's find a vector, perp, that is perpendicular to vec.
:[font = text; inactive; preserveAspect]
We do this by taking an arbitrary vector, and subtraction off the component parallel to vec.
:[font = text; inactive; preserveAspect]
Let's verify this is perpendicular:
:[font = text; inactive; preserveAspect]
Let's normalize perp:
:[font = text; inactive; preserveAspect]
perp2 is perp rotated by mat
:[font = text; inactive; preserveAspect; endGroup; endGroup]
The Cosine of the angle between perp and perp2 gives us the rotation angle.
^*)