<a name="docA_001">
2011-10-15-10-30 start
Rotation in 3D space has two
categories //axs2mat4.htm
First, mass point travel in space,
coordinate axis not move.
This is active picture.
Second,mass point not move.
coordinate axis rotate.
This is passive picture.
<a name="docA_002">axs2mat2.htm introduce passive
picture and derive equation 7.16
axs2mat4.htm introduce active
picture and derive p.75 eqn.(11)
<a name="docA_003">
Active/passive picture both start
from given rotation axis vector
and given rotation angle, solve
for rotation matrix.
<a name="docA_004">
This file mat2eul2.htm do a job
different from above. Here,
given rotation matrix R, and
find three elementary rotation
matrices E1,E2,E3, such that
R=Ek(θ3)*Ej(θ2)*Ei(θ1) ---eqn.m2e001
i,j,k=1,2,3 or =2,3,1 or ...
textbook page 8/15 eqn.(27)
<a name="docA_005">
A rotation matrix R is given,
why decompose R into Ek*Ej*Ei?
A simple reason is that matrix R
has axis vector point to arbitrary
direction. for example [1,2,3]
But elementary rotation matrices
have E1 axis, E2 axis and E3 axis
be [1,0,0] or [0,1,0] or [0,0,1].
<a name="docA_006">
The elementary rotation matrices
are very simple, and the original
rotation matrix R=Ek*Ej*Ei is
complicated.
<a name="docA_007">
Next is expert answer to
"why decompose R into Ek*Ej*Ei?"
Next is from textbook
[[
<a name="docA_008">
In a research program for a satellite
attitude control system it was found
advantageous to write the equations
of motion with the direction cosine
matrix as the kinematic variable. If
parameters such as Euler angles are
used for these variables, as is often
done, it is necessary to be able to
convert the direction cosine output
to Euler angles and the reverse.
<a name="docA_009">
The conversion of Euler angles to
direction cosines is simple and can
be performed by the multiplication
of elementary rotation matrices or
by the use of a standard (e.g., refs.
1,2, and 3) which gives the direction
cosine matrix in terms of Euler angles.
<a name="docA_010">
It is clear that the calculation of
the Euler angles from the direction
cosines is also possible, but a general
method was by no means obvious from
inspection of the equations involved
and no reference could be found that
gave a general method.
]]
<a name="docA_011">
The equation
R=Ek(θ3)*Ej(θ2)*Ei(θ1) ---eqn.m2e001
//Ek,Ej,Ei=rotation matrix, 3x3 matrix
say
the equivalent matrix to R is
first rotate θ1 angle along Ei axis
second rotate θ2 angle along Ej axis
third rotate θ3 angle along Ek axis
<a name="docA_012">
1,2,3 in θ1,θ2,θ3 represent rotation
sequence.
1,2,3 in Ek*Ej*Ei do NOT represent
rotation sequence.
//i,j,k =
// 1,2,3 or 2,3,1 or 3,1,2
//or 3,2,1 or 1,3,2 or 2,1,3
//or 1,2,1 or 2,3,2 or 3,1,3
//or 3,2,3 or 1,3,1 or 2,1,2
<a name="docA_013">
We say rotation sequence 1,2,3
why eqn.m2e001 use θ3,θ2,θ1 ?
that is why not use θ1,θ2,θ3 ?
The complete matrix equation is
ouVector=rm3*rm2*rm1*inVector ---eqn.m2e002
Next is wrong
ouVector=rm1*rm2*rm3*inVector ---eqn.m2e003 ERROR
//rm=rotation matrix, 3x3 matrix
<a name="docA_014">
In a matrix equation,
input vector is at very right end.
input vector must contact first
rotation matrix. Base on this
observation, eqn.m2e002 is right,
eqn.m2e003 is wrong.
<a name="docA_015">
We say rotation sequence xyz
in matrix multiplication zyx
We say rotation sequence zxy
in matrix multiplication yxz
etc.
<a name="docA_016">
rotation sequence zxy ?
what is z? what is x? what is y?
rotation x is rotation along [1,0,0]
it has next simple form
1 , 0 , 0
0 , cos(α) ,-sin(α) ---eqn.m2e004
0 ,+sin(α) , cos(α)
simplify as
1 , 0 , 0
0 , cα ,-sα ---eqn.m2e005
0 ,+sα , cα
<a name="docA_017">
rotation y is rotation along [0,1,0]
it has next simple form
cos(β) , 0 , +sin(β)
0 , 1 , 0 ---eqn.m2e006
-sin(β) , 0 , cos(β)
simplify as
cβ , 0 ,+sβ
0 , 1 , 0 ---eqn.m2e007
-sβ , 0 , cβ
<a name="docA_018">
rotation z is rotation along [0,0,1]
it has next simple form
cos(γ) ,-sin(γ) , 0
+sin(γ) , cos(γ) , 0 ---eqn.m2e008
0 , 0 , 1
simplify as
cγ ,-sγ , 0
+sγ , cγ , 0 ---eqn.m2e009
0 , 0 , 1
<a name="docA_019">
If rotation sequence is zyx,
combined rotation matrix is
[1, 0 , 0] [ cβ, 0,+sβ] [ cγ,-sγ, 0]
[0, cα ,-sα]*[ 0, 1, 0]*[+sγ, cγ, 0]
[0,+sα , cα] [-sβ, 0, cβ] [ 0, 0, 1]
[ +cβcγ , -cβsγ ,+sβ ]
=[+cαsγ+sαsβcγ,+cαcγ-sαsβsγ,-sαcβ] ---eqn.m2e010
[+sαsγ-cαsβcγ,+sαcγ+cαsβsγ,+cαcβ]
<a name="docA_020">
eqn.m2e010 has clear picture that
original matrix (second line) is
complicate, and the decomposition
(first line three matrices) are
all simpler matrices.
eqn.m2e010 decomposition is the
main goal of this file mat2eul2.htm
<a name="docA_021">
If set α=10 degree, β=20 degree and
γ=30 degree, first change degree to
radian, then the numerical version is
[1,0 , 0 ]
[0,0.984807753012208 ,-0.173648177666930]
[0,0.17364817766693033, 0.984807753012208]
*
[ 0.9396926207859084,0,0.3420201433256687]
[ 0 ,1,0 ]
[-0.3420201433256687,0,0.9396926207859084]
*
[0.8660254037844387 ,-0.49999999999999994,0]
[0.49999999999999994, 0.8660254037844387 ,0]
[0 , 0 ,1]
=
[ 0.8137976813493738,-0.46984631039295416, 0.3420201433256687]
[ 0.5438382409631008, 0.823172944645501 ,-0.1631759111665348]
[-0.20487411133804437,0.3187957775971678 , 0.9254165783983234]
2011-10-15-12-04 stop
<a name="docA_022">
2011-10-17-12-52 start
This file mat2eul2.htm change from
Rotation Matrix to Euler's Angle Sequence
and mat2eul2.htm is NOT done.
2011-10-17 upload NOT done version
to http://freeman2.com/mat2eul2.htm
Because
the program part is done
Control panel docB_xxx is done
which is usable now.
<a name="docA_023">
Equation derivation docA_xxx is
NOT done. Liu,Hsinhan decide
to stop use computer.
Because
<a name="docA_024">
Computer monitor vertical
direction is highly non-linear.
Desk top has ten rows icon.
Normally
upper half screen five rows and
lower half screen five rows icon.
<a name="docA_025">
Now start computer,
upper half screen three rows and
lower half screen seven rows icon.
after about two hours
upper half screen two rows and
lower half screen eight rows icon.
<a name="docA_026">
On 2011-10-11 all ten rows squeeze
to upper half screen, then extend
to full screen and jump to all ten
rows squeeze to upper half screen,
About three seconds one cycle.
Later become two seconds one cycle.
<a name="docA_027">
Everyday mouse pointer freeze few
times,
Everyday mouse pointer suddenly
jump to screen top and active
window (notepad or MSIE) auto
page-up or page-down one to two
pages.
<a name="docA_028">
2011-10-17-12-50 decide stop use
computer. freeman2.com will be
silent for long time.
Thank you for visit Freeman's
web site.
Freeman, Liu,Hsinhan 劉鑫漢
2011-10-17-13-09 stop
<a name="QBDraw"> 2011-10-15-15-55
Rotation in yz,zx,xy plane, coordinate axis is rotation axis.
All graph have two coordinate set, all be passive picture.
;
;
;
textbook
2011-10-10-11-14 open
rotMat2EulerAng_nasa.lnk
DIRECTION_COSINE_MATRIX_to_EULER_SEQUENCE_OF_ROTATIONS.pdf
A METHOD FOR EXPANDING A
DIRECTION COSINE MATRIX
INTO AN EULER SEQUENCE OF ROTATIONS
By George Meyer, Homer Q. Lee,
and William R. Wehrend, Jr.
Ames Research Center
Moffett Field, Calif.
2011-10-10-14-48
DIRECTION_COSINE_MATRIX_to_EULER_SEQUENCE_OF_ROTATIONS.pdf
page 6/15 use next rotation
[[
+cos(γ)*cos(β),+cos(γ)*sin(β)*sin(α)+sin(γ)*cos(α),-cos(γ)*sin(β)*cos(α)+sin(γ)*sin(α)
-sin(γ)*cos(β),-sin(γ)*sin(β)*sin(α)+cos(γ)*cos(α),+sin(γ)*sin(β)*cos(α)+cos(γ)*sin(α)
+sin(β),-cos(β)*sin(α),+cos(β)*cos(α)
+cγcβ,+cγsβsα+sγcα,-cγsβcα+sγsα
-sγcβ,-sγsβsα+cγcα,+sγsβcα+cγsα
+sβ,-cβsα,+cβcα
]]
above is generated by
rotate3d.htm#matrixBox04
z γ=1
y β=2
x α=3
matrix type A
Box21 output
cos(γ) ,+sin(γ) , 0
-sin(γ) , cos(γ) , 0
0 , 0 , 1
which is E3(θ3) in
DIRECTION_COSINE_MATRIX_to_EULER_SEQUENCE_OF_ROTATIONS.pdf
Box22 output
cos(β) , 0 , -sin(β)
0 , 1 , 0
+sin(β) , 0 , cos(β)
which is E2(θ2)
Box23 output
1 , 0 , 0
0 , cos(α) ,+sin(α)
0 ,-sin(α) , cos(α)
which is E1(θ1)
rotate3d.htm multiply to [==]
+cγcβ,+cγsβsα+sγcα,-cγsβcα+sγsα
-sγcβ,-sγsβsα+cγcα,+sγsβcα+cγsα
+sβ,-cβsα,+cβcα
DIRECTION_COSINE_MATRIX_to_EULER_SEQUENCE_OF_ROTATIONS.pdf
multiply to [==]
+cβcγ,+sαsβcγ+cαsγ,-cαsβcγ+sαsγ
-cβsγ,-sαsβsγ+cαcγ,+cαsβsγ+sαcγ
+sβ,-sαcβ,+cαcβ
2011-10-10-15-18
2011-10-10-16-42 open
JavaScript-Bible-5e.pdf
[[
As an example, the following
if...else construction determines
how many days are in
February for a given year. To
simplify the demo, the condition
simply tests whether the year
divides equally by 4. (True
testing for this value includes
special treatment of end-of-century
dates, but I’m ignoring that
for now.)
The % operator symbol is called
the modulus operator
(covered in more detail in
Chapter 32). The result of an
operation with this operator
yields
the remainder of division of
the two values. If the remainder
is zero, the first value divides
evenly by the second.
]]
2011-04-11-16-05
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19670017935_1967017935.pdf
A GIVEN DIRFCTION COSINE MATRIX
by
George Meyer, Homer Q. Lee
William R. Wehrend, Jr.
Ames Research Center, NASA
A GIVEN DIRFCTION COSINE MATRIX
SUBROUTINE EulerAng (I,J,K,A,TH)
DIMENSION X(3), Y(3), TH(3), A(3,3)
IF (I.EQ.K) GO TO 103
L = I - MOD(J,3)
IF (L.EQ.2) L = -1
C = L
X(1) = A(K,J)*C
Y(1) = A(K,K)
TH(1) = ARTN(X(1),Y(1))
X(1) = SIN(TH(1))
Y(1) = cos(TH(1))
101 X(3) = A(I,K)*X(1) - A(I,J)*C*Y(1)
Y(3) = A(J,J)*Y(1) - A(J,K)*C*X(1)
X(2) = -A(K,I)*C
Y(2) = A(I,I)*Y(3) + A(J,I)*C*X(3)
GO TO 104
103 N = 6 - (K + J)
X(1) = A(K,J)
L = N - MOD(I,3)
IF (L.EQ.2) L = -1
C = L
Y(1) = A(K,N)*C
TH(1) = ARTN(X(1), Y(1))
X(1) = SIN(TH(1))
Y(1) = COS(TH(1))
102 X(3) =-A(N,N)*X(1) + A(N,J)*C*Y(1)
Y(3) = A(J,J)*Y(1) - A(J,N)*C*X(1)
X(2) = A(J,I)*X(3) - A(N,I)*C*Y(3)
Y(2) = A(K,K)
104 TH(3) = ARTN(X(3),Y(3))
TH(2) = ARTN(X(2),Y(2))
RETURN
END
2011-10-10-16-58
function EulerAng(i,j,k,a)
{ //a010101820
//a010101838
var x=[], y=[]
var th=[]
var L;
var c;
var ii=i-1;
var jj=j-1;
var kk=k-1;
var nn;
if(i!=k)
{
L=i-j%3;
if(L==2)L=-1
c = L
x[0] = a[kk][jj]*c
y[0] = a[kk][kk]
th[0] = Math.atan2(x[0],y[0])
x[0] = Math.sin(th[0])
y[0] = Math.cos(th[0])
x[2] = a[ii][kk]*x[0] - a[ii][jj]*c*y[0]
y[2] = a[jj][jj]*y[0] - a[jj][kk]*c*x[0]
x[1] =-a[kk][ii]*c
y[1] = a[ii][ii]*y[2] + a[jj][ii]*c*x[2]
//expect precision 16 digits
//now only 6 digits,
//why low precision?
//a010141530
//did not find answer.
//
} //if(i!=k) the nonclassical or
//nonrepeating sequences. (above)
else
{ //if(i==k) the classical or
//repeating sequences (below)
n = 6 - (k + j)
nn=n-1;
x[0] = a[kk][jj]
L = n - (i)%3; //a010102110
if (L==2) L = -1
c = L
y[0] = a[kk][nn]*c
th[0] = Math.atan2(x[0], y[0])
x[0] = Math.sin(th[0])
y[0] = Math.cos(th[0])
//index in array must "-1"
//a010102122
//change [n] to [nn]
x[2] =-a[nn][nn]*x[0] + a[nn][jj]*c*y[0]
y[2] = a[jj][jj]*y[0] - a[jj][nn]*c*x[0]
x[1] = a[jj][ii]*x[2] - a[nn][ii]*c*y[2]
y[1] = a[kk][kk]
}
th[2] = Math.atan2(x[2],y[2])
th[1] = Math.atan2(x[1],y[1])
return th;
//a010102123
} //function EulerAng(i,j,k,a)
<a name="textbook">
2011-10-15-10-20 start
This page mat2eul2.htm use next
web page as textbook
On 2011-04-11-16-05 Liu,Hsinhan access
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19670017935_1967017935.pdf
A GIVEN DIRFCTION COSINE MATRIX by
George Meyer, Homer Q. Lee
William R. Wehrend, Jr.
Ames Research Center, NASA
March 10, 1967
125-19-03-09-00-21
2011-10-15-10-25 stop
<a name="matrix2EulerAngles">
Given rotation matrix, find
Euler Angles rotation sequence.
Main source: 2011-04-11-16-05 Liu,Hsinhan access
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19670017935_1967017935.pdf
A GIVEN DIRFCTION COSINE MATRIX by
George Meyer, Homer Q. Lee
William R. Wehrend, Jr.
Ames Research Center, NASA
March 10, 1967
125-19-03-09-00-21
rot.seq
; Example
; h3
;
h4
Next two lines are answer Euler Angles sequence:
Deg:
Rad:
Input rot.seq and Rad box,
h5 ,
three elementary matrix, then
multiply to one matrix. Matrix type
1,
2 //+sin() or -sin()
h6
ONLY radio button 1 and radio button number get answer.
Output three elementary matrix
sin() & cos() ,
number
box2
output multiplied matrix
h7
Hsinhan wait for wife Liling until last breath !
a010142139
Box 7 number to Box 8. Round 0.4999999 and 1.20000003
h9
3x3 matrix determinant: Box
QAboxa08.value='Str8';
<a name="docB_001">
2011-10-14-18-52 start
How to use the program
EulerAng(i,j,k,a) ?
Input, click, output as
following.
<a name="docB_002">
in [box1 input 3*3 rotation matrix]
input a numerical 3*3 rotation
matrix. Ex. have three
simple examples.
Example [01] first rot x α=120
no second, no third rotation.
[01] matrix trace=0.
Example [02] first rot z γ=6
second rot y β=18, no third.
Example [03] first rot x α=30
second rot y β=20 degree
third rot z γ=10 degree
Above is box1 input
<a name="docB_003">
Below is rot.seq input
Fill in [1,2,3] for
1st rot x, 2nd y, 3rd z.
Fill in [3,2,3] for
1st rot z, 2nd y, 3rd z.
There are twelve possibilities.
1,2,3; 2,3,1; 3,1,2; 3,2,1;
1,3,2; 2,1,3; no repeat six
1,2,1; 2,3,2; 3,1,3; 3,2,3;
1,3,1; 2,1,2; repeat six.
Above is input boxes, only two.
<a name="docB_004">
Below is click button
Click to run
output to Deg and Rad two
long boxes.
<a name="docB_005">
Twelve sequence pattern have
simple click buttons.
use rot.seq 1,2,3
use rot.seq 2,1,3
etc.
Degenerated sequence 1,2,2 has
no click button. User can fill
1,2,2 to rot.seq input box and
click to run
but output has no use.
2011-10-14-19-17 here
Above is and 12
<a name="docB_006">
Below is
The second step is to build
three elementary rotation matrix.
Input is Rad long box, it has
three rotation angles in radian.
Second input is rotation sequence.
<a name="docB_007">
Assume Rad box has 1.1, 2.2, 3.3
Assume rotation sequence is
zyx ; 3,2,1 Click
output 3rd rot mat to Box 4,
around axis 1 angle 3.3 rad
output 2nd rot mat to Box 5,
around axis 2 angle 2.2 rad
output 1st rot mat to Box 6,
around axis 3 angle 1.1 rad
<a name="docB_008">
Box 4,5,6 have the main result
of this file.
Above Rad box value from box1
<a name="docB_009">
Below Rad box value from Deg box
User can assign three rotation
radian angles to Rad box.
Use comma to separate number.
User can assign three rotation
degree angles to Deg box.
then click button to get
radian angles in Rad box.
<a name="docB_010">
Above is angle, below is sequence.
User can not change zyx ; 3,2,1
value. Input rotation sequence
to rot.seq box.
Use 1,2,3 do not use x,y,z.
When both angle and sequence
are done, click for answer
at box 4,5,6.
Above build three rot.matrix.
<a name="docB_011">
Below verify three rot.matrix.
When three elementary rotation
matrix are in hand, we need to
verify 3rdMat*2ndMat*1stMat is
the same as box 1 matrix.
Please click
Input are box4, box5, box6.
<a name="docB_012">
Output to box2. That is
box2=box4*box5*box6
If box1 has original matrix,
program also output to box3
and one line above box3.
<a name="docB_013">
Box 3 is also a 3x3 matrix.
But it is relative errors.
Box2 matrix relative to Box1
matrix. Nine errors. Take
absolute value for each error
and average error displayed
one line above box3.
<a name="docB_014">
If program run smooth,
average error is in order of
2.e-8
If something wrong,
average error is in order of
0.5
<a name="docB_015">
There are two sets radio buttons
[[
Matrix type ◎1, ◎2 //+sin() or -sin()
ONLY radio button 1 and
radio button number get answer.
Output three elementary matrix
◎sin() & cos() , ◎number
]]
<a name="docB_016">
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19670017935_1967017935.pdf
program written for
Matrix type ◎1
If click type ◎2
Average error is about 0.5
Result is not usable.
<a name="docB_017">
type ◎1 is next
cos(θ) ,+sin(θ) , 0
-sin(θ) , cos(θ) , 0
0 , 0 , 1
type ◎2 is next
cos(θ) ,-sin(θ) , 0
+sin(θ) , cos(θ) , 0
0 , 0 , 1
<a name="docB_018">
Second set radio button is
◎sin() & cos() , ◎number
If click ◎sin() & cos()
output to
cos(θ) ,+sin(θ) , 0
-sin(θ) , cos(θ) , 0
0 , 0 , 1
<a name="docB_019">
If click ◎number
output to
0.984807753012208,0.17364817766693033,0
-0.17364817766693033,0.984807753012208,0
0,0,1
<a name="docB_020">ONLY radio button 1 and
radio button number get answer.
other choice are prepared for
think purpose.
2011-10-14-20-03 stop
<a name="docB_021">
2011-10-14-21-02 start
This file mat2eul2.htm change
from function bye09v02(in09)
to function bye09v03(in09)
If input is 0.49999999999999994
bye09() should return 0.5
but error occurred
<a name="docB_022">
2011-10-13-11-25 found
input is 0.49999999999999994
bye09v02(0.49999999999999994)=
0.5000001 <== this is error
bye09v02(0.49999999999999999)=
0.5000001 <== this is error
bye09v02(0.4999999999999999)=
0.5 <== this is correct
<a name="docB_023">
0.5=0.5000000000000000 has 16
precision digits.
but 0.5000001000000000 has 6
precision digits.
It is a big error.
<a name="docB_024">
bye09v03(in09) change at
add nineEnd and code a010131440
now
bye09v03(0.49999999999999994)=
0.5 <== this is correct
<a name="docB_025">
In box 7 fill in
0.4999999999999999999999999
Please click
Box 8 output correct answer 0.5
2011-10-14-21-13 stop
<a name="docB_026">
The following will be deleted
in final version.
2011-04-11-16-05
http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19670017935_1967017935.pdf
DIRECTION_COSINE_MATRIX_to_EULER_SEQUENCE_OF_ROTATIONS.pdf
2011-10-12-21-14 a010122114
why
mat2eul2.htm
a010121726
precision reduce to 7 digit?
it should be 16 digits
2011-10-12-08-58
rotate3d.htm#all27rot
1st: x γ=30
2nd: y β=20
3rd: z α=10
1st: box23, x γ=30 deg.
1,0,0
0,0.8660254037844387,0.49999999999999994
0,-0.49999999999999994,0.8660254037844387
2nd: box22, y β=20 deg.
0.9396926207859084,0,-0.3420201433256687
0,1,0
0.3420201433256687,0,0.9396926207859084
3rd: box21, z α=10 deg.
0.984807753012208,0.17364817766693033,0
-0.17364817766693033,0.984807753012208,0
0,0,1
box21*box22*box23
get
0.9254165783983234,0.3187957775971678,-0.20487411133804437
-0.16317591116653482,0.823172944645501,0.5438382409631008
0.3420201433256687,-0.46984631039295416,0.8137976813493738
above is matrix in
mat2eul2.htm
box1