Rotation matrix from rotation axis and angle way2
Equation derivation, 3D graph geometric construction.
txt docA QA QB QC QD ; upload 2011-10-05
XYGraph v2.3 - web page graph   ☜☞   donate   get code

This file is personal home work. No one
proofread. Cannot promise correctness.
If you suspect any view point wrong,
please ask a math expert near by.
Freeman 2009-06-19-10-46

Please use MSIE browser to read this file.
Did not test other browser. This file is
written under MSIE 6.0

<a name="docA_001">

2011-09-22-18-51 start
Previous study notes //local
http://freeman2.com/axs2mat2.htm  
topic is
Rotation matrix from rotation axis 
and angle, Equation derivation, 
3D graph geometric construction. 

This file axs2mat4.htm has same 
topic, the difference is that
axs2mat2.htm rotate coordinate axis
axs2mat4.htm rotate mass point.

<a name="docA_002">
axs2mat2.htm textbook is 
Jack B.Kuipers 
ISBN 978-0-691-10298-6
page 162 to 165.
bottom of page 165, 
equation 7.16 is main target.

axs2mat4.htm textbook is 
Simon L. Altmann 
ISBN 0-486-44518-6
page 162,163, conclusion at
page 75 equation (11)

<a name="docA_003">
Rotation axis unit vector and 
rotation angle are both given.
Ask to find rotation matrix.
Use n for rotation axis unit vector.
Use r for unit vector before rotation.
Use Rr for result of r rotation.
Length of Rr must be one, because
rotation preserve length and angle.
Uppercase R represent Rotation. If 
view from mathematics 
R is rotation matrix. The goal of 
this file is to find matrix R 

<a name="docA_004">
Although program require rotation
axis length be one, but user can 
input any length (not zero) vector,
program auto adjust length to one.
The unit vector is n=ON vector in 
QADraw  .

Starting vector r project to n at 
M. On vector r=OA, point A take M
as center and rotate to point B.
Point C is middle point of AB.
In calculation, point C is more 
important than point B.

<a name="docA_005">
Numerical example is tangible.
result vector = rotation matrix * initial vector
is next
//matrix has axis=[1,2,3] angle=60deg.
[0.93130] [ 0.53571,-0.62294, 0.57005] [3]
[3.56592]=[ 0.76579, 0.64286,-0.01717]*[2]
[0.64560] [-0.35577, 0.44574, 0.82143] [1]
    // ---eqn.amb001 
in which, initial vector=[3,2,1]
 result vector=[0.9313,3.56592,0.6456]
Both length are not one. because
example problem do not involve 
proof process.

<a name="docA_006">

rotation matrix is
[ 0.53571,-0.62294, 0.57005]
[ 0.76579, 0.64286,-0.01717] ---eqn.amb002 
[-0.35577, 0.44574, 0.82143]

Matrix determinant value is 0.9999991240430879
Accurate determinant value: 1.0000000000000...

<a name="docA_007">
Please see QADraw  
(suggest open another window)
Following need three auxiliary
vectors, all start from point A
which is tip of vector r=OA.
v=AM from point A to circle center M
u=AD tangent to circle at point A.
a=AC half length of AB.
We require tangent length AD has 
|AM|=|AD|=radius ρ. All three 
auxiliary vectors have length 
less than one.

<a name="docA_008">
We require a=AC half of AB and
not use AB, because 
  AC/AM=sin(φ/2) ---eqn.amb003
//please see QADraw 
AC and radius AM has trigonometric
relation, bur AB does not.
2011-09-22-20-31 stop

<a name="docA_009"> 'cmp'=compare
2011-09-22-23-20 start
axs2mat2.htm use direct method.
axs2mat4.htm use indirect method.
//QCDraw  
Direct method do not use start
or result vectors.
Indirect method use start vector
and result vector. Find rotation
matrix between these two vectors  
via geometric construction.

Direct method use rotated (bird 
body) coordinate system, project
rotated i,j,k unit vectors to 
ground I,J,K coordinate system.
Find three projections nine 
components and use them to build
rotation matrix.
//Please see QCDraw 
Indirect method do not use bird 
body coordinate system.

<a name="docA_010">
Coordinate direction elements i,j,k 
are three "vectors" each length be
one. //"vecsel" ? VECtor'S ELement 
vecsel length be one and
vecsel has no physics dimension
vecsel is NOT vector, NOT pseudo.
vecsel is vector's building brick.
No one use "vecsel" 向元 a009271610
Same as digit 0 to 9, digits are 
not real and not imaginary either.
vecsel is Liu,Hsinhan fabricated 
term. Everyone say unit vectors 
are pseudo vectors, Pseudo are not 
real vectors. see tute0054.htm
2011-09-22-23-35 here //local

<a name="docA_011">

About "Direct method project
rotated i,j,k unit vectors to 
ground I,J,K coordinate system."
Please see axs2mat2.htm //online
click QADraw axs2mat2.htm  
click QBDraw axs2mat2.htm  
click QCDraw axs2mat2.htm  
In axs2mat2.htm 
from [a name="docA_001"]
 to  [a name="docA_107"] has 
derivation for rotation matrix.
2011-09-22-23-52 stop

<a name="docA_012">
2011-09-23-11-08 start
The current page, derivation 
for rotation matrix, first step
is to find relation among 
result vector Rr≡OB 
given rot.axis n≡ON、
given rot.angle φ≡∠AMB and
start vector r≡OA
Please see QADraw 
<a name="docA_013">
In above graph, it is not easy 
to see the following relations
  |ON|=|OA|=|OB|=1 ---eqn.amb004 
  ∠OMA=∠OMB=90゜ ---eqn.amb005
  ∠MAD=∠MCA=90゜ ---eqn.amb006
From QADraw "3D graph", write 
next equation
   OB     =    OA    +  AB ---eqn.amb007 
resultVec = startVec + chord

The main task is to find relation
among AB, n, φ, r.

<a name="docA_014">
MAB is isosceles triangle. Half
of AB is AC. AC and radius AM 
have trigonometric relation
  AC/AM=sin(φ/2) ---eqn.amb003
It is easy to see above equation 
at QADraw .

<a name="docA_015">
We find AC in terms of n, φ, r 
Double it to get AB. Define 
three auxiliary vectors vua
  AM=v ---eqn.amb008 //radius
  AD=u ---eqn.amb009 //tangent
  AC=a ---eqn.amb010 //halfWay
We set the following condition
for tangent end point D
  |AM|=|AD|=ρ=radius ---eqn.amb011
From 3D graph it is easy to see
radius AM is less than one.
∵|OA|=|OB|=|ON|=1 , ∵ AM⊥OM 
∴AM=OA*sin(∠AOM)<1 
//'∵'=because. '∴'=therefore
<a name="docA_016">

Use mathematics equation to 
express geometry relation
halfWay vector a start vector r
and result vector Rr are related by
  a=(Rr-r)/2 ---eqn.amb012
Vector 2a start at r and end at Rr.
vector=end-start=(Rr-r)/2 is correct
but start-end=(r-Rr)/2 is WRONG

<a name="docA_017">
Re-write eqn.amb012 for Rr as following
  Rr=2*a+r ---eqn.amb013
u and v both link to n and r.
But halfWay a no link to n, r.
We need find how a link to u and v
If success, we can find how a link 
to n and r. (both n and r are given)
<a name="docA_018">
Because auv are all on one plane, 
we require the next relation 
  a=p*u+q*v ---eqn.amb014
p,q are proportional coefficients,
we find p, q at later time. eqn.amb014 
is textbook page 163 equation (1).

<a name="docA_019">
Next find how p、u、q、v link to n, r, φ.

Please see QADraw
Tangent u, rotation axis n and start 
vector r have the following relation
  u=n×r ---eqn.amb015 //AD=ON×OA
In QADraw "3D graph" use right hand for 
thumb up. Four fingers curve 
from ON to OA, thumb point to 
AD direction.
<a name="docA_020">
Magnitude of tangent AD is
  |AD|=|OA|*|ON|*sin(∠AON)=|AM| ---eqn.amb016
  |AD|= 1  * 1  *sin(∠AON)=|AM|
Earlier
[[
We set the following condition
for tangent end point D
  |AM|=|AD|=ρ=radius ---eqn.amb011
]]
is justified.

<a name="docA_021">

Above relate u to n and r, eqn.amb015
Below relate v to n and r, eqn.amb017

Still use QADraw "3D graph" In your
brain, please parallel move vector
ON such that point O coincide with A.
Use "pON" to describe parallel moved
vector ON. (graph did not draw it)
pON⊥AD, because in eqn.amb015, AD is
the result of cross product ON×OA
pON⊥AM, because pON is axis and
         AM is radius. M is 
         projection on ON
AM⊥AD, because AD is tangent at A.
<a name="docA_022">
pON,AM,AD three vectors are 
perpendicular to each other.
Let pON cross product with AD 
to find direction of AM, that is
  AM=pON×AD ---eqn.amb018
  v =  n ×u ---eqn.amb019
AM is v,AD is u, both are correct.
But n is rotation axis and 
pON is parallel moved ON. Are they
the same? Because parallel move 
do not change direction, therefore
n and pON can be substituted
freely. Question? Please ask a 
math expert near by.

<a name="docA_023">
eqn.amb019 generated vector v which 
has magnitude and direction. Check
as following.
pON,AM,AD are perpendicular to
each other. From right hand rule
n×u get direction of v.
On the other hand, u×n is wrong.
Magnitude of v is |n|*|u|*sin(90゜)
Because we require 
  |n|=1  ---eqn.amb020
and require 
  |r|=1  ---eqn.amb021
//eqn.amb019 not use eqn.amb021
<a name="docA_024">
Trigonometric relation has
sin(90゜)=1 therefore |v|=1*|u|*1=|u|
|AM|=|v| = |u|=|AD| ---eqn.amb022
Earlier has
[[
for tangent end point D
  |AM|=|AD|=ρ=radius ---eqn.amb011
]]
They are consistent. eqn.amb019 has
correct magnitude and direction.

<a name="docA_025">
We need link v to n and r, but
eqn.amb019 relate v to n and u. 
Replace u! Substitute eqn.amb015 
into eqn.amb019, get 
  v=n×(n×r) ---eqn.amb017

2011-09-23-12-48 stop
2011-09-23-14-29 start

<a name="docA_026">

Above relate v to n and r, eqn.amb017
Below relate p to rotation angle φ, 
eqn.amb023

Please see QADraw
Angle φ≡∠AMB is rotation angle.
AM and MB are both radius, 
∆AMB is isosceles triangle
  ∠AMC=∠BMC=φ/2 ---eqn.amb024
<a name="docA_027">
In ∆AMC, ∠ACM is right angle.
In ∆AMC, AM is v, AC is a.
v and a have next relation
  sin(φ/2) = |a|/|v|
           = AC/AM ---eqn.amb025
Review
<a name="docA_028">
  a=p*u+q*v ---eqn.amb014
We know radius v=AM is perpendicular 
to tangent u=AD 
Let a dot product with u get
  au=(p*u+q*v)‧u ---eqn.amb026
that is
  au=p*uu + q*vu ---eqn.amb027
Because vu therefore vu=0 
eqn.amb027 become
  au=p*uu ---eqn.amb028
Above au come from eqn.amb014
<a name="docA_029">
Below au come from ∠CAD
Please see QADraw
∠CAD has simple geometry relation
∠CAD+∠CAM=90゜=∠CMA+∠CAM 
cancel ∠CAM, get
 ∠CAD=∠CMA=φ/2 we need
  ∠CAD=φ/2 ---eqn.amb029
then //reference, tangent u=AD
  au=|a|*|u|*cos(∠CAD) ---eqn.amb030
that is
  au=AC*|u|*cos(φ/2) ---eqn.amb031

<a name="docA_030">
Let eqn.amb031 equal eqn.amb028 get
  au=next line both side
  AC*|u|*cos(φ/2)=p*uu ---eqn.amb032
<a name="docA_031">

From eqn.amb032 find p get
  p = AC*|u|*cos(φ/2)/|u|/|u| ---eqn.amb033
  p = AC*cos(φ/2)/|u| //cancel one |u|
  p = (AC/|u|)*cos(φ/2) //ref. tangent u=AD
  p = (AC/AD)*cos(φ/2) //∆CAD is not right triangle
      //Apply eqn.amb011≡eqn.amb022 AD=AM
  p = (AC/AM)*cos(φ/2) //⊿CAM is right triangle
  p = sin(φ/2)*cos(φ/2) ---eqn.amb034

<a name="docA_032">
HalfWay AC to all the way AB 
multiply by two, get
 2p =2*sin(φ/2)*cos(φ/2) 
 2p =  sin(φ)  ---eqn.amb023

2011-09-23-15-48 stop
2011-09-23-18-04 start

<a name="docA_033">
Above is p link to φ, eqn.amb023
Below is q link to φ, eqn.amb035

Find q use same method as 
find p .
Review
<a name="docA_034">
  a=p*u+q*v ---eqn.amb014
radius v=AM is perpendicular 
to tangent u=AD 
Let a dot product with v get
  av=(p*u+q*v)‧v ---eqn.amb036
that is 
  av=p*uv + q*vv ---eqn.amb037
Because vu then vu=0,
eqn.amb037 become
  av=q*vv ---eqn.amb038
Above av come from eqn.amb014
<a name="docA_035">
Below av come from right triangle 
⊿CAM. Please see QADraw
⊿CAM has simple geometry relation
  ∠CMA=φ/2 ---eqn.amb039
therefore //NOT ∠CAM=φ/2 ←this one error
  av=|a|*|v|*cos(∠CAM) ---eqn.amb040
∠CAM is not φ/2, we do not want 
cos(∠CAM).
<a name="docA_036">

Because ∠CAM+∠CMA=90゜, then 
  cos(∠CAM)=sin(∠CMA) ---eqn.amb041
We want ∠CMA=φ/2, eqn.amb040 become
  av=|a|*|v|*sin(∠CMA) ---eqn.amb042
that is
  av=AC*|v|*sin(φ/2) ---eqn.amb043

<a name="docA_037">
Let eqn.amb043 equal eqn.amb038, get
  av=next line both side
  AC*|v|*sin(φ/2)=q*vv ---eqn.amb044
<a name="docA_038">
From eqn.amb044 find q get
  q = AC*|v|*sin(φ/2)/|v|/|v| ---eqn.amb045
  q = AC*sin(φ/2)/|v| //cancel one |v|
  q = (AC/|v|)*sin(φ/2) //ref. v=AM
  q = (AC/AM)*sin(φ/2) //⊿CAM is right triangle
  q = sin(φ/2)*sin(φ/2) ---eqn.amb046

<a name="docA_039">
HalfWay AC to all the way AB 
multiply by two, get
 2q =2*sin(φ/2)*sin(φ/2)  ---eqn.amb035
2011-09-23-18-42 here

<a name="docA_040">
Complete equation is
  Rr=2*a+r ---eqn.amb013
in which
  a=p*u+q*v ---eqn.amb014
and
  u=n×r ---eqn.amb015
  v=n×(n×r) ---eqn.amb017
  2p =  sin(φ)  ---eqn.amb023
  2q =2*sin(φ/2)*sin(φ/2)  ---eqn.amb035

<a name="docA_041">

Substitute u,v,p,q  into a
substitute a into eqn.amb013 get 

Rr=r+sin(φ)*n×r+2*sin(φ/2)*sin(φ/2)*n×(n×r) ---eqn.amb047

<a name="docA_042">
eqn.amb047 is textbook page 163 line 5,
equation (2).
eqn.amb047 is complete rotation
equation, but we can not use it,
because it involve arbitrary 
start vector r. 
Our goal is from given axis vector n 
and given rotation angle φ to find 
rotation matrix. We do not need r.
2011-09-23-19-00 stop

<a name="docA_043"> 'DOr'=main goal isolate r
2011-09-23-20-01 start
eqn.amb047 has the following form
  Rr=f(n,φ,r)  ---eqn.amb048
We need change it to
  Rr=g(n,φ)*r  ---eqn.amb049
f(n,φ,r) mean n,φ,r mixed together.
g(n,φ)*r mean n,φ and r are separable.
then g(n,φ) is rotation matrix R。

<a name="docA_044">
In eqn.amb047 the trouble one is 
n×(n×r). Assume we have three vectors
abc, next relations are true
  (a×bc=(ac)b-(bc)a ---eqn.rod092
  a×(b×c)=(ac)b-(ab)c ---eqn.rod093
eqn.rod092 and eqn.rod093 come from //local
http://freeman2.com/tute0055.htm
Proof of eqn.rod092 is at tute0055.htm#a055_077
The following use eqn.rod093 directly

<a name="docA_045">
eqn.amb047 
  Rr=r+sin(φ)*n×r+2*sin(φ/2)*sin(φ/2)*n×(n×r)
Above has Trigonometric identity
  2*sin(φ/2)*sin(φ/2)=1-cos(φ) ---eqn.amb050
after replace with 1-cos(φ) 
eqn.amb047 become //next ---eqn.amb051
  Rr=r+sin(φ)*n×r+(1-cos(φ))*n×(n×r)
eqn.amb047 has sin() only, has φ and φ/2
eqn.amb051 has sin() and cos(), has φ only.

<a name="docA_046">

eqn.amb051 has three terms
term1 r 
term2 +sin(φ)*n×r
term3 +(1-cos(φ))*n×(n×r)
First step rewrite n×(n×r)

In eqn.rod093 let a=n and b=n and c=r
  a×(b×c)=(ac)b-(ab)c ---eqn.rod093
become
  n×(n×r)=(nr)n-(nn)r ---eqn.amb052
<a name="docA_047">
Substitute eqn.amb052 
into  +(1-cos(φ))*n×(n×r) //term3
get   +(1-cos(φ))*[(nr)n-(nn)r] ---eqn.amb053
it is +(1-cos(φ))*(nr)n
      +(1-cos(φ))*[-(nn)r] ---eqn.amb054
since |n|=1 then nn=1,eqn.amb054 become
term3 +(1-cos(φ))*(nr)n
term3 -(1-cos(φ))*r ---eqn.amb055

<a name="docA_048">
Substitute eqn.amb055 back to 
eqn.amb051 get
  Rr=r+sin(φ)*n×r
     +(1-cos(φ))*(nr)n
     -(1-cos(φ))*r ---eqn.amb056
Merge first term r and 
last term -(1-cos(φ))*r 
get eqn.amb057 , now eliminated n×(n×r)
<a name="docA_049">
Rr=cos(φ)*r+sin(φ)*n×r +(1-cos(φ))*(nr)n ---eqn.amb057

below is earlier eqn.amb047 and 
below has trouble term n×(n×r)
<a name="docA_050">   //above [table] , below [p]

Rr=r+sin(φ)*n×r+2*sin(φ/2)*sin(φ/2)*n×(n×r) ---eqn.amb047

<a name="docA_051">


When rotation angle is zero, start
vector and end vector should be
identical. Whether above two 
equations satisfy this requirement?
Can you verify?

eqn.amb057 is textbook page 163 
line 7, equation (4).
eqn.amb057 is complete rotation 
equation, we still can not use 
it, but now eliminated n×(n×r)
Done most part.
2011-09-23-21-02 stop

<a name="docA_052"> 
'NOr'=NO r vector, eqn.amb049 isolate r
2011-09-24-10-28 start
eqn.amb047 and eqn.amb057 both
have the form of eqn.amb048
  Rr=f(n,φ,r)  ---eqn.amb048
The following, change eqn.amb057
to the form of eqn.amb049
  Rr=g(n,φ)*r  ---eqn.amb049
<a name="docA_053">
eqn.amb057 has three terms
  Rr=  //add three terms = eqn.amb057
    cos(φ)*r  //termA ---eqn.amb058
   +sin(φ)*n×r //termB ---eqn.amb059
   +(1-cos(φ))*(nr)n //termC ---eqn.amb060

<a name="docA_054">
eqn.amb001 left side is a 
three row one column vector.
Right side is a three row three 
column matrix multiply with 
three row one column vector.
eqn.amb001 is equality, it says
that 3x3 matrix multiply column
vector get another column vector.
Similarly, 
<a name="docA_055">
eqn.amb057 is column vector 
equation, it can be written 
as 3x3 matrix multiply column
vector. We want to isolate r.

Exam termA first.
  cos(φ)*r ---eqn.amb058
TermA's r is already 
isolated. cos(φ) is a single
number. How can we write one 
number as a 3x3 matrix. That 
is right, it is not possible 
to write a number as a 3x3 
matrix.
<a name="docA_056">

We can manage column vector r.
There is a special matrix, the
identity matrix [I]
    [ 1  0  0 ]
[I]=[ 0  1  0 ] ---eqn.amb061
    [ 0  0  1 ]
identity matrix 'convert' input
vector to its original form.
that is no rotate at all.
no rotate for any input vector,
<a name="docA_057">
  r=[I]r ---eqn.amb062
[I] multiply vector is like 
number multiplication 1*5 
This "1*" and "[I]*" both are
redundant. We can drop them 
at any time. When condition is
right, We can insert them at 
any time. Now insert [I].
<a name="docA_058">
rewrite termA
  cos(φ)*r ---eqn.amb058
as following
[ 1  0  0 ]
termA=cos(φ)* [ 0  1  0 ] r  ---eqn.amb063
[ 0  0  1 ]
<a name="docA_059">
Next see termB eqn.amb059
   +sin(φ)*n×r  ---eqn.amb059
in which
<a name="docA_060">
[n1]
vector n= [n2] ---eqn.amb064
[n3]

<a name="docA_061">
[r1]
vector r= [r2] ---eqn.amb065
[r3]
<a name="docA_062">
Freshman calculus tell us that cross product
of two vectors n×r can be written as next

[
i
  
j
  
k
]
n×r= [ n1    n2    n3 ] ---eqn.amb066
[ r1    r2    r3 ]
<a name="docA_063">
eqn.amb066 still can not isolate r。
expand eqn.amb066 as following
  n×r= ---eqn.amb067
  i*(n2*r3-n3*r2)
  j*(n3*r1-n1*r3)
  k*(n1*r2-n2*r1)

<a name="docA_064">
eqn.amb067 has three rows, we
need each row contains r1,r2,r3.
So that we can take out the 
common term [r1,r2,r3]
Rewrite eqn.amb067 as following
  n×r= ---eqn.amb068
  i*(  0*r1 -n3*r2 +n2*r3)
  j*( n3*r1 + 0*r2 -n1*r3)
  k*(-n2*r1 +n1*r2 + 0*r3)

<a name="docA_065">
eqn.amb068 has three rows,
each row has r1,r2,r3. Take 
out the common term [r1,r2,r3] 
What left is a 3x3 matrix.
Result is the following
  n×r= ---eqn.amb069
  [  0  -n3  +n2] [r1]
  [ n3  + 0  -n1]*[r2]
  [-n2  +n1  + 0] [r3]

<a name="docA_066">

'+', '-' in eqn.amb068 are addition/subtraction
'+', '-' in eqn.amb069 are positive/negative
'+', '-' in eqn.amb069 are NOT addition/subtraction
Since eqn.amb069 contain a 3x3 
matrix, which has nine elements.

<a name="docA_067">
Now eqn.amb069 isolated r, termB
   +sin(φ)*n×r  ---eqn.amb059
become
  termB= ---eqn.amb070
         [  0  -n3  +n2] [r1]
 +sin(φ)*[ n3  + 0  -n1]*[r2]
         [-n2  +n1  + 0] [r3]

2011-09-24-11-56 stop

<a name="docA_068">
2011-09-24-13-25 start
Above is termB, below is termC
   +(1-cos(φ))*(nr)n  ---eqn.amb060

"+(1-cos(φ))*" is a constant 
not participate taking out r
calculation. Focus point is (nr)n

<a name="docA_069">
nr is dot product of two vectors.
n is eqn.amb064
r is eqn.amb065, do as following
  nr=n1*r1+n2*r2+n3*r3 ---eqn.amb071
The result of dot product is a 
scalar, not a vector, not a matrix.

<a name="docA_070">
scalar "(1-cos(φ))" not involve r calculation,
scalar "n1*r1+n2*r2+n3*r3" do involve.
Since the first do not contain r and
second has r.

<a name="docA_071">

Refer to eqn.amb071,(nr)n become
  (nr)n=
  i*[n1*(n1*r1+n2*r2+n3*r3)]
 +j*[n2*(n1*r1+n2*r2+n3*r3)] ---eqn.amb072
 +k*[n3*(n1*r1+n2*r2+n3*r3)]

<a name="docA_072">
i,j,k three components come from n,
expand eqn.amb072 get
  (nr)n= ---eqn.amb073
  i*[n1*n1*r1 + n1*n2*r2 + n1*n3*r3]
 +j*[n2*n1*r1 + n2*n2*r2 + n2*n3*r3]
 +k*[n3*n1*r1 + n3*n2*r2 + n3*n3*r3]
//above '+' are addition, not positive

<a name="docA_073">
Three rows in eqn.amb073 all have 
r1,r2,r3, wonderful, take out
[r1,r2,r3] get
  (nr)n= ---eqn.amb074
  [n1*n1  n1*n2  n1*n3] [r1]
  [n2*n1  n2*n2  n2*n3]*[r2]
  [n3*n1  n3*n2  n3*n3] [r3]

<a name="docA_074">
we have
  (1-cos(φ))*(nr)n= ---eqn.amb075
           [n1*n1  n1*n2  n1*n3] [r1]
(1-cos(φ))*[n2*n1  n2*n2  n2*n3]*[r2]
           [n3*n1  n3*n2  n3*n3] [r3]
<a name="docA_075">
eqn.amb057
Rr=cos(φ)*r+sin(φ)*n×r +(1-cos(φ))*(nr)n ---eqn.amb057



all three terms isolated r, rewrite eqn.amb057 as following
<a name="docA_076"> 'lng'=LoNG equation
[
cos(φ)
  
0
  
0
]
Rr= [
0
  
cos(φ)
  
0
] r ---eqn.amb076
[
0
  
0
  
cos(φ)
]
[
0
  
-sin(φ)*n3
  
+sin(φ)*n2
]
 + 
[
sin(φ)*n3
  
0
  
-sin(φ)*n1
] r
[
-sin(φ)*n2
  
sin(φ)*n1
  
0
]
[
(1-cos(φ))*n1*n1
  
(1-cos(φ))*n1*n2
  
(1-cos(φ))*n1*n3
]
 + 
[
(1-cos(φ))*n1*n2
  
(1-cos(φ))*n2*n2
  
(1-cos(φ))*n2*n3
] r
[
(1-cos(φ))*n1*n3
  
(1-cos(φ))*n2*n3
  
(1-cos(φ))*n3*n3
]
Add three matrix to one to get answer.
2011-09-24-14-16 stop

<a name="docA_077">
2011-09-24-15-17 start
Three matrices has 27 terms. For 
identification purpose, set 
eqn.amb076 as following
  Rr=Ar+Br+Cr ---eqn.amb077
R,A,B,C all be 3 row, 3 column 
matrices
row1, col1 is R11,A11,B11,C11
row1, col2 is R12,A12,B12,C12
row1, col3 is R13,A13,B13,C13
Similarly for row2 and row3.

<a name="docA_078">
The following work need 
normalization relation
  |n|=1  ---eqn.amb020
Which say vector length be one
  n1*n1+n2*n2+n3*n3=1 ---eqn.amb078

<a name="docA_079">
Row1, col1 three elements sum
  R11=A11+B11+C11
     =cos(φ)+0+(1-cos(φ))*n1*n1
     //add "*1" on purpose
     =cos(φ)*1+(1-cos(φ))*n1*n1
     //apply eqn.amb078
     =cos(φ)*(n1*n1+n2*n2+n3*n3)
     +(1-cos(φ))*n1*n1
     //expand
     =cos(φ)*n1*n1+cos(φ)*(n2*n2+n3*n3)
     +n1*n1-cos(φ)*n1*n1
     //cancel +/- cos(φ)*n1*n1
     =n1*n1+(n2*n2+n3*n3)*cos(φ) ---eqn.amb079

<a name="docA_080">
Row1, col2 three elements sum
  R12=A12+B12+C12
     =0-sin(φ)*n3+(1-cos(φ))*n1*n2
     =n1*n2*(1-cos(φ))-n3*sin(φ) ---eqn.amb080

<a name="docA_081">

Row1, col3 three elements sum
  R13=A13+B13+C13
     =0+sin(φ)*n2+(1-cos(φ))*n1*n3
     =n1*n3*(1-cos(φ))-n1*sin(φ) ---eqn.amb081

<a name="docA_082">
Row2, col1 three elements sum
  R21=A21+B21+C21
     =0+sin(φ)*n3+(1-cos(φ))*n1*n2
     =n1*n2*(1-cos(φ))+n3*sin(φ) ---eqn.amb082

<a name="docA_083">
Row2, col2 three elements sum
  R22=A22+B22+C22 ---eqn.amb083
     =cos(φ)+0+(1-cos(φ))*n2*n2
     =cos(φ)*1+(1-cos(φ))*n2*n2
     =cos(φ)*(n1*n1+n2*n2+n3*n3)
     +(1-cos(φ))*n2*n2
     =cos(φ)*n2*n2+cos(φ)*(n1*n1+n3*n3)
     +n2*n2-cos(φ)*n2*n2
     =n2*n2+(n1*n1+n3*n3)*cos(φ)

<a name="docA_084">
Row2, col3 three elements sum
  R23=A23+B23+C23
     =0-sin(φ)*n1+(1-cos(φ))*n2*n3
     =n2*n3*(1-cos(φ))-n1*sin(φ) ---eqn.amb084

<a name="docA_085">
Row3, col1 three elements sum
  R31=A31+B31+C31
     =0-sin(φ)*n2+(1-cos(φ))*n1*n3
     =n1*n3*(1-cos(φ))-n2*sin(φ) ---eqn.amb085

<a name="docA_086">

Row3, col2 three elements sum
  R32=A32+B32+C32 ---eqn.amb086
     =0+sin(φ)*n1+(1-cos(φ))*n2*n3
     =n2*n3*(1-cos(φ))+n1*sin(φ)

<a name="docA_087">
Row3, col3 three elements sum
  R33=A33+B33+C33
     =cos(φ)+0+(1-cos(φ))*n3*n3
     =cos(φ)*1+(1-cos(φ))*n3*n3
     =cos(φ)*(n1*n1+n2*n2+n3*n3)
     +(1-cos(φ))*n3*n3
     =cos(φ)*n3*n3+cos(φ)*(n1*n1+n2*n2)
     +n3*n3-cos(φ)*n3*n3
     =n3*n3+(n1*n1+n2*n2)*cos(φ) ---eqn.amb087

Substitute eqn.amb078 ... eqn.amb087 
to eqn.amb076 get
<a name="docA_088">

Rr= // ---eqn.amb088
[ n1n1+(n2n2+n3n3)cφ n1n2(1-cφ)-n3sφ n1n3(1-cφ)+n2sφ ] [r1]
[ n1n2(1-cφ)+n3sφ n2n2+(n1n1+n3n3)cφ n2n3(1-cφ)-n1sφ ]*[r2]
[ n1n3(1-cφ)-n2sφ n2n3(1-cφ)+n1sφ n3n3+(n1n1+n2n2)cφ ] [r3]

Above n1,n2,n3 are elements of rotation axis vector n=[n1,n2,n3]
n length be one, that is n1n1+n2n2+n3n3=1 ---eqn.amb078
Dropped "*" , n1*n2 simplify to n1n2. Other terms are the same.
cφ≡cos(φ) , sφ≡sin(φ) , φ is rotation angle.
<a name="docA_089">
eqn.amb088 is the final rotation matrix
of previous study notes //local
http://freeman2.com/axs2mat2.htm#docA3Mat
eqn.amb088 is textbook equation
Quaternions and Rotation Sequences
Jack B.Kuipers, ISBN 978-0-691-10298-6  
page 162 to 165. p.165 equation 7.16

But eqn.amb088 is not this file axs2mat4
textbook final answer. 
Continue work as following.
2011-09-24-16-10 stop

<a name="docA_090">
2011-09-24-19-17 start
In eqn.amb088 three diagonal 
elements R11,R22,R33 can be 
re-write as following
R11=n1n1+(n2n2+n3n3)cφ +0
   =n1n1+(n2n2+n3n3)cφ+(n1n1cφ-n1n1cφ)
   =n1n1+(n1n1+n2n2+n3n3)cφ-n1n1cφ
   =+(1)cφ +n1n1-n1n1cφ
R11=cφ +n1n1(1-cφ) ---eqn.amb089
Similarly
R22=cφ +n2n2(1-cφ) ---eqn.amb090
R33=cφ +n3n3(1-cφ) ---eqn.amb091

<a name="docA_091">

2011-05-09-20-40 Liu,Hsinhan access
http://scipp.ucsc.edu/~haber/ph116A/rotation_11.pdf
page 6/19, equation (17) is next

R(n,θ)= // ---eqn.amb092
[ cθ+n1n1(1-cθ)    n1n2(1-cθ)-n3sθ    n1n3(1-cθ)+n2sθ ]
[ n1n2(1-cθ)+n3sθ    cθ+n2n2(1-cθ)    n2n3(1-cθ)-n1sθ ]
[ n1n3(1-cθ)-n2sθ    n2n3(1-cθ)+n1sθ    cθ+n3n3(1-cθ) ]

<a name="docA_092">
eqn.amb092 has only rotation matrix,
no mass point starting vector r。

This file axs2mat4.htm textbook 
Rotations, Quaternions, and Double 
Groups by Simon L. Altmann 
ISBN 0-486-44518-6 page 75 equation
is next
<a name="docA_093">

R(φn)= // ---eqn.amb093 textbook p.75 eqn.(11) rot.matrix
[ 1-2(n2n2+n3n3)*(sφ/2)2   -n3sφ+2n1n2*(sφ/2)2   +n2sφ+2n1n3*(sφ/2)2 ]
[ +n3sφ+2n1n2*(sφ/2)2   1-2(n1n1+n3n3)*(sφ/2)2   n2n3*(sφ/2)2-n1sφ ]
[ n1n3*(sφ/2)2-n2sφ   n2n3*(sφ/2)2+n1sφ   1-2(n1n1+n2n2)*(sφ/2)2 ]

rotation axis is n=[n1,n2,n3], rotation angle is φ
n1n2≡n1*n2 , (sφ/2)2≡sin(φ/2)*sin(φ/2) , sφ≡sin(φ)
If rotation angle is zero, matrix MUST be identity matrix
Whether above equation is reasonable? Can you verify?
2011-09-24-20-13 stop
<a name="docA_094">
2011-09-24-20-55 start
Next explain that 
matrix in eqn.amb093 [R] and 
matrix in eqn.amb088 [S] are identical.
 
eqn.amb093 matrix elements are R11,R12,...R33
eqn.amb088 matrix elements are S11,S12,...S33
change eqn.amb088 cos() to eqn.amb093 sin()

<a name="docA_095">
We need next trigonometric identity
  2*sin(φ/2)*sin(φ/2)=1-cos(φ) ---eqn.amb050
Need vector length equation
  n1*n1+n2*n2+n3*n3=1 ---eqn.amb078

<a name="docA_096">

Next prove R11≡S11
R11=1-2(n2n2+n3n3)*sφ/2*sφ/2 ---eqn.amb094
S11=n1n1+(n2n2+n3n3)cφ ---eqn.amb095

R11= 1-2(n2n2+n3n3)*sφ/2*sφ/2 
    //use eqn.amb050
   = 1-(n2n2+n3n3)*(1-cos(φ))
   = 1-(n2n2+n3n3)+(n2n2+n3n3)*cos(φ)
    //use eqn.amb078
   = n1*n1+n2*n2+n3*n3-(n2n2+n3n3)
    +(n2n2+n3n3)*cos(φ)
   =n1n1+(n2n2+n3n3)cφ = S11 ---eqn.amb096

<a name="docA_097">
Next prove R12≡S12
R12=-n3sφ+2n1n2*sφ/2*sφ/2 ---eqn.amb097
S12=n1n2(1-cφ)-n3sφ ---eqn.amb098

R12=-n3sφ+2n1n2*sφ/2*sφ/2 
    //use eqn.amb050
   = n1n2(1-cφ)-n3sφ = S12 ---eqn.amb099

<a name="docA_098">
Next prove R13≡S13
R13=+n2sφ+2n1n3*sφ/2*sφ/2  ---eqn.amb100
S13=n1n3(1-cφ)+n2sφ  ---eqn.amb101

R13=+n2sφ+2n1n3*sφ/2*sφ/2 
    //use eqn.amb050
   = n1n3(1-cφ)+n2sφ = S13 ---eqn.amb102

<a name="docA_099">
Other six elements are the same
as above three. Reader can try it.

Here done the proof of eqn.amb093
2011-09-24-21-26 stop

<a name="docA_100">

2011-09-26-11-18 start
The final equation is eqn.amb093
first  conclusion  is eqn.amb088
Other web page result eqn.amb092
Three different source, three different
appearance matrices are identical !
We can say: "One problem, one answer"
<a name="docA_101"> 'que'=question

If reader think carefully, reader 
will find puzzle.
We have two different proof methods 
We have two geometric constructions 
 First axs2mat2 QBDraw button. 
Second axs2mat4 QADraw button.

Please compare two graph, do you
have any question? Please think 
first, then continue. So that 
you can compare your observation 
with LiuHH's observation.
2011-09-26-11-53 here







<a name="docA_102">
2011-09-26-11-55 start
Earlier axs2mat2 and this axs2mat4 
both start from given rotation axis
and given rotation angle, both ask 
to find rotation matrix.
Two methods have very different 
principle.

<a name="docA_103">
Rotation has two categories.
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.
The terms "active picture" and
"passive picture" are used in
textbook page 30.
<a name="docA_104">
The next discussion 
use "point rotate, axis static" 
for  first category rotation.
use "point static, axis rotate" 
for second category rotation.

If it is "point rotate, axis static" 
we have only one coordinate system,
and point has starting vector and 
result vector.
On the other hand,
<a name="docA_105">
If it is "point static, axis rotate"
problem has two sets coordinate system,
although point not move relative to 
space, but point has one [X,Y,Z] and
one [x,y,z] readings. Two coordinates 
have different numerical value, but
they describe same point in space.
Because there are two sets coordinate 
systems.
<a name="docA_106">

Find "point static, axis rotate" at
file axs2mat2.htm textbook by Jack B.Kuipers 
page 162 to 165, ISBN 978-0-691-10298-6

Find "point rotate, axis static" at
file axs2mat4.htm textbook by Simon L. Altmann 
page 162,163 and 75. ISBN 0-486-44518-6

<a name="docA_107">
Kuipers use point static, axis rotate,
Altmann use point rotate, axis static.
It is wonderful companion, let reader
understand two different approaches.
//Please see QCDraw  
2011-09-26-12-31 here

<a name="docA_108">
2011-09-26-14-24 start
axs2mat4 QADraw  indicate
result vector = matrix * start vector
It has no question.
axs2mat2 QBDraw  indicate
ground vector = matrix * bird vector?
or
bird vector = matrix * ground vector?
Which is correct?
"bird vector" is mass point express 
location in space via rotated coordinate 
system. Bird fly/rotate in any direction.
"ground vector" is mass point express 
location in space via ground coordinate 
system. ground do not change direction.
<a name="docA_109"> 'VX'= correct V or error X
If confuse, refer to eqn.amb093
"result vector = matrix * start vector
 It has no question." and guess that
eqn.amb088 operation rule is 
bird vector = matrix * ground vector ---eqn.amb103 ERROR
Do you agree? The correct answer is
ground vector = matrix * bird vector ---eqn.amb104
<a name="docA_110">
Compare next both correct equations
vec. before rot = passive matrix * vec.  after rot ---eqn.amb105
vec.  after rot = active  matrix * vec. before rot ---eqn.amb106
"vec" in eqn.amb105 is QCDraw 
"vec" in eqn.amb106 is QCDraw 
passive matrix≡active  matrix
eqn.amb106 is the main topic of axs2mat4
eqn.amb088 and eqn.amb106 are the same type.
But the derivation in axs2mat2 never
mention (never need) mass point vector
therefore new hands may be confused 
to use eqn.amb103 or eqn.amb104.

<a name="docA_111">

Why
ground vector = matrix * bird vector ---eqn.amb104
is correct? We find answer from 
the structure of rotation matrix.
axs2mat2.htm equation 7.16 document is
[[
Column 1 (red) bird body (1,0,0) components on ground coord. system
Column 2 (green) bird body (0,1,0), Column 3 (black) bird body (0,0,1)
]]
<a name="docA_112">
axs2mat2.htm docA_011 explain as next
[[
After we find 
(x1,x2,x3), (y1,y2,y3), (z1,z2,z3)
write it in matrix form
| x1  y1  z1 |
| x2  y2  z2 | ---eqn.axs009
| x3  y3  z3 |
then our job is done. 
Why eqn.axs009 is rotation matrix?
Please see rotate3d.htm#docA_002
]]
<a name="docA_113">
Ground coordinate system has X,Y,Z 
unit vectors (vecsel, length be one
and no physics unit)
Bird coordinate system has x,y,z 
unit vectors. Now treat x,y,z as
three vectors relative to ground.
  x=[x1,x2,x3] ---eqn.amb107
  y=[y1,y2,y3] ---eqn.amb108
  z=[z1,z2,z3] ---eqn.amb109

<a name="docA_114">
Bird system unit vectors x,y,z all 
take components in ground coordinate 
system, please see next 
2011-09-26-15-31 here
<QCDraw> How to construct rotation matrix? Please see QCDraw

QCDraw Bird coordinate project to ground coordinate

Hsinhan wait for wife Liling until last breath ! a009201142

<a name="docA_115">
2011-09-26-19-11 start
Please see QCDraw 
Red, green, black are three unit vectors 
of after_rotate (bird) coordinate system.
Red broken line is bird x axis 
three components m11,m21,m31 
measured on ground system.
Blue broken line is bird y axis 
three components m12,m22,m32
measured on ground system.
Black broken line is bird z axis 
three components m13,m23,m33
measured on ground system.
<a name="docA_116">

Put nine components in the following
order
 [m11  m12  m13]
 [m21  m22  m23] ---eqn.amb110
 [m31  m32  m33]
This is rotation matrix. Assume 
<a name="docA_117">
Before_rotate vector r=[r1, r2, r3] ---eqn.amb111
 After_rotate vector s=[s1, s2, s3] ---eqn.amb112
Complete rotation equation is
 [s1] [m11  m12  m13] [r1]
 [s2]=[m21  m22  m23]*[r2] ---eqn.amb113
 [s3] [m31  m32  m33] [r3]
<a name="docA_118"> 'pro'=property
What is the property of nine 
matrix elements? Let us set
r=[r1, r2, r3]=[1, 0, 0] ---eqn.amb114
put in eqn.amb113, get
 [s1] [m11  m12  m13] [1]
 [s2]=[m21  m22  m23]*[0] ---eqn.amb115
 [s3] [m31  m32  m33] [0]
<a name="docA_119">
expand
 [s1] [m11*1+m12*0+m13*0]
 [s2]=[m21*1+m22*0+m23*0] ---eqn.amb116
 [s3] [m31*1+m32*0+m33*0]
answer is
 [s1] [m11]
 [s2]=[m21] ---eqn.amb117
 [s3] [m31]

<a name="docA_120">
[m11, m21, m31] is created by us.
[m11, m21, m31] is bird x axis 
projection on ground system.
then, after_rotate vector 
  s=[s1, s2, s3] ---eqn.amb112
is bird x axis [1,0,0] projection 
on ground coordinate system.

<a name="docA_121">

Bird x axis measured on bird 
system, read [1, 0, 0]
then, before_rotate vector 
  r=[r1, r2, r3] ---eqn.amb111
is a reading in bird system.
before_rotate vector can not be
a reading relative to ground !
therefore, rotation equation is
 [gro] [m11  m12  m13] [bird]
 [und]=[m21  m22  m23]*[body] ---eqn.amb118
 [val] [m31  m32  m33] [valu]
(eqn.amb093 and eqn.amb118 are the same type)
<a name="docA_122"> //eqn.amb119 ≡ eqn.amb118
Next, bird axis measured on ground
 [gro] [bird  bird  bird] [bird]
 [und]=[x, i  y, j  z, k]*[body] ---eqn.amb119
 [val] [axis  axis  axis] [valu]

Above "bird  x,i  axis" is bird body 
coordinate system x axis unit vector i 
projection on ground coordinate system.
"bird  x,i  axis" IS "m11 m21 m31"
"bird  y,j  axis" and "bird  z,k  axis" 
are the same.

Above "bird body valu" measured on 
bird (rotated) coordinate system.
Above "gro und val" is same point
measured on ground coordinate system.
eqn.amb119 3x3 matrix transform from
bird body (x,y,z) to ground (X,Y,Z)
Mass point stay in space never move.
<a name="docA_123">
Transpose of a rotation matrix is
same as inverse of rotation matrix
We have next
 [bird] [m11  m21  m31] [gro]
 [body]=[m12  m22  m32]*[und] ---eqn.amb120
 [valu] [m13  m23  m33] [val]
2011-09-26-19-37 here

Above is the case of axs2mat2 QBDraw  
<a name="docA_124">
Below is the case of axs2mat4 QADraw 

Mass point start coordinate value and 
result coordinate value are both measured 
relative to ground, here no bird.
Coordinate reading eqn.amb093 is same 
as eqn.amb121
 [end] [m11  m12  m13] [bgn]
 [pt.]=[m21  m22  m23]*[pt.] ---eqn.amb121
 [val] [m31  m32  m33] [val]
<a name="docA_125">
Transpose is same as inverse,
We have next
 [bgn] [m11  m21  m31] [end]
 [pt.]=[m12  m22  m32]*[pt.] ---eqn.amb122
 [val] [m13  m23  m33] [val]

<a name="docA_126">
Above elements name m11,m12 ... m33 are
symbols only. eqn.amb118 and eqn.amb121 
have real version, please see eqn.amb088
eqn.amb092 and eqn.amb093.

<a name="docA_127">

Please see QCDraw 
this graph has a point P 
P project to gray ground coord. 
system is red line OCDP
P project to blue bird coord. 
system is green line OABP

<a name="docA_128">
Jack B.Kuipers rotation matrix 
derivation, change OABP to OCDP.
Point P never show up.

<a name="docA_129">
Please see QCDraw 
This graph has one start point A
and end point B, mass P (no mark)
move from A to B. In this graph,
no bird coordinate system.
Graph "move along arc" and 
graph "two projections" are very
different.

Hope above  
three graphs help you to understand.

<a name="docA_130">
Another small observation.
Textbook author Simon L. Altmann did 
not take eqn.amb088 as final answer,
Take few more steps to replace 
all cos() with sin() and take 
eqn.amb093 as final answer. Why?

Because later part in textbook
discuss infinitesimal. Assume
θ be infinitesimal angle, it has
the following simplification
  sin(θ)≈θ ---eqn.amb123
and
  sin(θ/2)*sin(θ/2)≈θ*θ/4 ---eqn.amb124

<a name="docA_131">
Relative to first power of infinitesimal
square of infinitesimal can be neglected
That is to drop terms contain 
sin(θ/2)*sin(θ/2) For this purpose,
author Altmann choose eqn.amb093 as 
final answer.

<a name="docA_132">

Above work are all Liu,Hsinhan's 
study notes. Follow textbook closely.
hope no error in this file. But no 
one proofread this file. When you 
read, please suspect every step. 
If you have question, please ask 
a math expert near by. If this file
contain errors, hope reader can 
tolerate, since Liu,Hsinhan's 
capability is limited.

Thank you for visiting Freeman's 
web site.
Liu,Hsinhan 劉鑫漢
2011-09-26-20-09

2011-09-27-11-25 start translation
2011-09-28-15-07 translate to here

<a name="textbook">
2011-09-22-18-16 start
This file axs2mat4.htm use next
book as textbook
Rotations, Quaternions, 
and Double Groups 
ISBN 0-486-44518-6
Simon L. Altmann 
Page 162,163 and page 75 equation (11) 
2006-07-06 order book $12.97
2006-07-19 receive book
2011-09-22-18-18 stop





<a name="QADraw">

QADraw Bgn ▲ and end ● both on circle. ◆ is middle of ▲●
Draw tangent |▲X|=radius |■▲|
Hsinhan wait for wife Liling until last breath ! a009201142






<a name="QBDraw">

Please use MSIE to read this page.
Rotation matrix from rotation axis and angle way2
Graph area size, W: H:
x min: , x max: ; y min: , y max: ;
x,y value below should be within range above.
Ground (fixed) 3D perpendicular unit vector set,
color= , width= , SoliDot=
"bgn" vector is user supplied arbitrary vector.
"end" vector is result of "bgn" vector rotation. default cws
bgn color= , width= , solidot=
end color= , width= , solidot=
tri color= , width= , solidot=
tan color= , width= , solidot=
axs color= , width= , solidot=
Axes cross at x= , y= , ;
Zenith angle from the positive z-axis phi φ //north pole φ=0
Azimuth angle from positive x-axis theta θ //Greenwich θ=0
Spherical coordinate radial distance rho ρ //earth center ρ=0
Next line is spherical φ,θ,ρ to x,y,z converter
; ;
; ;
Click above "eye,up,axis,begin" to convert φ,θ,ρ to x,y,z at below
Program do not read above 4 boxes, only read 5 boxes below.
eye xyz  
up xyz
normalized rotation axis output here
quaternion generated rotation matrix determinant
delete next three boxes ; del
begin vector Why provide x,y,z buttons? Please see here
axis vector , angle degree
begin vector use
If not draw, try Click 3D / view / norm to run
QBDraw; $Draw

change min/max x/y
$Draw
Hsinhan wait for wife Liling until last breath ! a009201142
Box11, output XYGraph code

Box12, output 2D x,y data

Box13, output 3D x,y,z data

Box14, output tangent vector

$Draw
If begin vector is [1,0,0] or [0,1,0] or [0,0,1], watch end vector
Box15, output rotation matrix

matrix2axis Box15 matrix output axis/angle to Box16。
number angle/axis generated rotation matrix. Test purpose.
Box16, output angle/axis equation derivation

random number matrix has dead corner, because angle/axis are all positive. QBboxc16.value='string'






<a name="docB_001">

2011-09-29-12-57 start
QBDraw output two rotation matrix.
axis rotation matrix output to box15
cake rotation matrix output to box21
axis matrix is defined by axis and angle.
cake matrix rotate 2D XY cake to 3d xyz.
cake is used to describe the red circle.
axis four bytes, cake four bytes too.
<a name="docB_002">
rotation matrix in box15 is the main 
topic of this file.

rotation matrix in box15 rotate one 
start vector to result vector.
rotation matrix in box21 rotate easy
to draw XY plane circle to right 
place circle in 3D xyz space.

<a name="docB_003">
If start vector is [1,0,0] or [0,1,0]
or [0,0,1] then on top of box15 print
the result vector let user to verify.
If input vector is [1,0,0] then result 
vector should be first COLUMN of box15 
rotation matrix.

<a name="docB_004">
If input vector is [0,1,0],then result 
vector should be second COLUMN of box15 
rotation matrix.

If input vector is [0,0,1],then result 
vector should be third COLUMN of box15 
rotation matrix.

<a name="docB_005">
If different, must be code error.
Liu,Hsinhan tested several input data
result be correct. more

Above verification can NOT be used 
for box21 rotation matrix.
2011-09-29-13-10 stop

<a name="docB_006">

2011-09-29-14-48 start
If click [top norm], at bottom of 
graph print a line similar to next
up xyz -0.47104265983994076,-0.6377557105469491,0.6094148556407778
If paste above three numbers to 
[up xyz] box and click [3D rotate]
get same output. Because above three
numbers are [top norm] code used up 
direction.
2011-09-29-14-51 stop

<a name="docB_007">
2011-09-29-14-57 start
At [QBDraw; $Draw] if click 
 program read user [eye xyz] 
and [up xyz]. If click  
program read user [eye xyz] but 
replace [up xyz] with [axis vector] 
(put eye on axis)

<a name="docB_008">
If click  program do not read 
user eye up boxes. program replace 
[up xyz] with [axis vector] and program 
calculate up direction, let isosceles 
triangle base line be vertical, and 
print up vector at bottom of drawing
board. QADraw top view graph use 
QBDraw top norm output, line AB vertical. 
not use top view, line AB not vertical.
2011-09-29-15-06 stop

<a name="docB_009">
2011-10-02-14-15 start
Please goto QBDraw,click ,change 
drawing board min/max x/y to -1 to +1. 
Then click , change input vector to 
[0.62,1.78,-0.53] Next click , 
what you get is nothing, blank drawing 
board. MSIE window lower left corner 
show up error icon. Now click .
change min/max x/y to -1.5 to +1.5 
Next click  get graph output.
After add tangent line code, tangent
end point exceed "-1 to +1" and program
stop draw. Change to "-1.5 to +1.5" 
solve problem. Output is smaller.
2011-10-02-14-29 stop

<a name="docB_010">
2011-10-02-14-46 start
axs2mat2.htm and axs2mat4.htm
both read user input rotation axis
vector and rotation angle. Both 
find rotation matrix. Two pages 
use different method to prove.
There is another difference.
axs2mat2.htm do not read arbitrary
start vector. Only draw ground XYZ
and bird xyz two coordinate systems
and draw three disks.
<a name="docB_011">

axs2mat4.htm read arbitrary start 
vector and draw just one disk.
If axs2mat2.htm and axs2mat4.htm
have same rotation angle, same 
rotation axis same eye up data,
then in axs2mat4.htm assign start
vector to be [1,0,0] 
axs2mat4.htm output graph same as
axs2mat2.htm  button graph.
Similarly, [0,1,0] match  and 
[0,0,1] match <a name="docB_012">
"same" mean two files draw same 
big circle, same rotation axis,
same start vector, same end vector.
but difference is that
axs2mat2.htm draw path.
axs2mat4.htm draw isosceles triangle
2011-10-02-15-17 stop

<a name="docB_013">
2011-10-04-16-35 start
function aa2m()  not normalize input vector
function KuipersEq0716() will 
normalize input vector
Both function do same thing.
When write aa2m() 
ignored KuipersEq0716()
2011-10-04-16-37 stop






2011-09-25-13-25 start
Next is a small tool which find rotation angle and rotation axis for a given rotation matrix. Another web page rotate3d.htm has similar function. input at box4 output to box5. but,rotate3d require high accuracy otherwise stop run. Program below run any way and report determinant value, let user decide answer is ok or junk. If determinant value differ from one greater than 1.e-6, this output has no value. 1.e-6 is suggest value, User can use other standard.
2011-09-25-13-38 stop
Box21, input 3 by 3 rotation matrix matrix to axis


Box21 matrix to Box22 ; Example
;

Box22, Output rotation angle and axis






2011-09-25-17-45 start
Next is a small tool program. Input rotation angle and rotation axis vector at box31. Output rotation matrix to box32. This page axs2mat4.htm main result is rotation matrix Next program is the numerical version of main result.
The key code is out3=aa2m(inp3); aa2m = angle,axis to matrix
Box31 input line one is angle, default degree. If add "//rad" right to number , this number is radian. Example
1.23 //rad
the number 1.23 is radian. But
1.23 // rad
the number 1.23 is degree, because blank ' ' void rad.

Box31 input line two is axis vector three numbers. Separate number with comma. User no need input length one vector. Program normalize vector.
Web page rotate3d.htm has similar function. Input at [Ang/Axis in/out] four boxes (up/down four boxes) Click button is [From rot.angle, rot.axis find ] Output to rotate3d.htm box01
2011-09-25-18-10 stop
Box31, Inout rotation angle and axis vector

Example ; axis to matrix

Box32, output 3x3 rotation matrix goto box21





<a name="v1v2DotCross"> vector Dot/Cross product

v1:  
v2:  
an:
Please fill vectors into boxes v1, v2, output to "an" box.
[v1 dot v2] require vector dimension greater than one.
[v1 cross v2] require vector dimension be three. a010051026





<a name="docL_001">

2011-09-22-17-12
Start from 2011-06-02 Liu,Hsinhan's
computer monitor begin distortion.
Black cloud cover upper half screen.
Text or curve in upper half screen 
become taller and lower half screen
text or curve become shorter.
Around 2011-07-30, distortion to 
worst condition.
Around 2011-08-2?, computer monitor
return to normal.
2011-09-20 start write axs2mat3.htm
2011-09-22 computer monitor begin 
distortion again. If draw a circle,
upper half circle elongated, lower 
half circle compressed.
2011-09-22-17-21

<a name="docL_002">
2011-09-26-18-57
2011-09-22 distortion slightly
2011-09-26 distortion heavier.
2011-09-26-18-58

<a name="docL_003">
2011-09-26-23-00 start
This file axs2mat4.htm omit control
panel document, because axs2mat4.htm 
and axs2mat2.htm are very close.
axs2mat2.htm has document.

<a name="docL_004">
The main reason is that LiuHH's 
computer monitor distort again.
Today 2011-09-26 distort heavier.
Expect on 2011-09-30 upload this 
file axs2mat3.htm (Chinese version).
From 2011-09-27 to 2011-09-30 write 
axs2mat4.htm (English) Expect on 
2011-09-30 monitor distort to worst 
condition.

<a name="docL_005">
Can not predict the condition after 
2011-09-30. Besides monitor distortion,
LiuHH's HP pavilion a255c power on 
push button has trouble about one 
year ago. Sometime push button to
turn on computer, but button not 
spring back, then computer on, off, 
on, off. LiuHH can not solve this 
hardware trouble.
2011-09-26-23-10 stop

<a name="docL_006">

2011-10-03-10-54 start
Translate to here. 
The monitor is about same level as 
2011-09-26. Turn on switch not 
better, slight worse.
LiuHH hoped to upload axs2mat4.htm
on 2011-09-30, but in fact, the 
time is too short to finish the 
work. (10 days from 2011-09-20 to 
2011-09-30)
2011-10-03-10-59 stop





Javascript index
http://freeman2.com/jsindex2.htm   local
Save graph code to same folder as htm files.
http://freeman2.com/jsgraph2.js   local





file name axs2mat4.htm mean
rotation AXiS to rotation MATrix English (4) .htm
Chinese version is axs2mat3.htm

This file
Rotation matrix from rotation axis and angle way2
Equation derivation, 3D graph geometric construction.
http://freeman2.com/axs2mat4.htm
First upload 2011-10-05

Thank you for visiting Freeman's page
Freeman Liu,Hsinhan 劉鑫漢
2011-10-03-11-23