Decomposition of an arbitrary SO(3,R) rotation R(n,θ) into composition of three consequtive rotationsR((Subscript[n, 1]),(Subscript[θ, 3]))R((Subscript[n, 2]),(Subscript[θ, 2]))R((Subscript[n, 1]),(Subscript[θ, 1]))where (Subscript[n, 2]).(Subscript[n, 1])=0

Authors

Veliko Donchev, Clementina Mladenova and Ivaïlo M. Mladenov
July 30, 2015

This free Mathematica program is supplementary to the paper   On the Generalized Euler Resolutions of Rotations
by V. Donchev, C. Mladenova and I. Mladenov  
published in  Comptes rendus de l’Acad´emie bulgare des Sciences  68 (2015) 815-824.

INPUT:

Initial rotation in terms of angle θ and axis n

nInput={-1,17,-8}; (* INPUT HERE THE AXIS OF THE INITIAL ROTATION. IT NEED NOT TO BE UNIT. *)
θ=π/7; (* INPUT HERE THE ANGLE OF TOTATION. *)

Axes (Subscript[n, 1]) and (Subscript[n, 2]). Enter the two nonzero axes. If they are not entered orthogonal, Gram-Schmidt procedure will be performed automatically.

n1Input={1,-3,2}; (* INPUT HERE THE AXIS n1. IT NEED NOT TO BE UNIT. *)
n2Input={-2,3,1};  (* INPUT HERE THE AXIS n2. IT NEED NOT TO BE UNIT. *)

Precision for the numerical results in the end

prec=3;

No more input is expected.

n2Input.n1Input (* The scalar product of the input vectors *)

lnitialization

Used Procedures

Rod[{u_,v_,w_},θ_]:=Cos[θ]IdentityMatrix[3]+(1-Cos[θ])(({{(u^2), u v, u w}, {v u, (v^2), v w}, {w u, w v, (w^2)}}))+ Sin[θ](({{0, -w,  v}, {w, 0, -u}, {-v, u, 0}}));(* This is a method for matrix construction of a Rotation of angle θ about an axis n = (u,v,w) using the Rodrigues' representation. *)
GramSchmidt2[n1_,n2_]:=Module[{λ,M1,M2,m1,m2},
(* INPUT: n1,n2;
     Performs Gram Schmidt procedure to the nonzero INPUT vectors n1 and n2.
  RETURNS  normalized pair (m1,m2) such that span(n1,n2)=span(m1,m2) and m1 is the direction of n1.
*)
M1=n1;
λ=-((n2.M1)/(M1.M1));
M2=n2+λ M1;
m1=M1/Norm[M1];
m2=M2/Norm[M2];
{m1,m2}
]

Initialization

n=nInput/Norm[nInput]; (* Normalization of the axis of the initial rotation. *)
RotationM=Rod[n,θ];(* Matrix construction of the initial Rotation. *)

{n1,n2}=GramSchmidt2[n1Input,n2Input](* Obtaining unit and perpendicular pair (n1,n2) from the INPUT vectors  *)

n2.n1//N (* Check if perpendicular axes are entered. *)

Finding the angles (Subscript[θ, 1]),(Subscript[θ, 2]) and (Subscript[θ, 3]) according to Theorem 2

Formula 2.40 : Determining (Subscript[θ, 2])

θ2=2ArcSin[(Sqrt[1-(((n.n1))^2)])Sin[(θ/2)]];
θ2≤ π && θ2≥0

Formula 2.38 : Determining (Subscript[δ, 1])

δ1=If[Abs[θ]== π,Sign[n.n1](π/2),ArcTan[(n.n1)Tan[(θ/2)]]];
δ1≤ π/2 && δ1≥ -π/2

Formula 2.39 : Determining (Subscript[δ, 2])

δ2=If[n.n2==0,Sign[n.(n1 \[Cross]n2)](π/2),ArcTan[((n.(n1 \[Cross]n2))/(n.n2))]];
δ2≤ π/2 && δ2≥ -π/2

Formulas 2.36, 2.37: Determining (Subscript[θ, 1]) and (Subscript[θ, 3])

n.n2//N  (* Check the numetical value of n.(Subscript[n, 2]). *)

θ1=If[n.n2≥  0, δ1-δ2,δ1-δ2+π];(* Determining (Subscript[θ, 1]). *)
θ3=If[n.n2≥  0,δ1+δ2,δ1+δ2+π]; (* Determining (Subscript[θ, 3]). *)

Check of the intervals for (Subscript[θ, 1]) and (Subscript[θ, 3])

(θ1≤ 2π&& θ1≥0) && (θ3≤ 2π&& θ3≥0)(* Must hold true if n.(Subscript[n, 2]) < 0. *)

(θ1≤ π&& θ1≥-π) &&(θ3≤ π&& θ3≥-π)(* Must hold true if n.(Subscript[n, 2]) ≥  0. *)

Numetical check of the result

This will be made by comparison of the initial rotation matrix and the composition matrix R((Subscript[n, 1]),(Subscript[θ, 3]))R((Subscript[n, 2]),(Subscript[θ, 2]))R((Subscript[n, 1]),(Subscript[θ, 1]))

R1=Rod[n1,θ1];  (* Matrix construction of R((Subscript[n, 1]),(Subscript[θ, 1])). *)
R2=Rod[n2,θ2]; (* Matrix construction of R((Subscript[n, 2]),(Subscript[θ, 2])). *)
R3=Rod[n1,θ3];(* Matrix construction of R((Subscript[n, 1]),(Subscript[θ, 3])). *)
Rcomposite=R3.R2.R1;  (* Matrix construction of R((Subscript[n, 1]),(Subscript[θ, 3]))R((Subscript[n, 2]),(Subscript[θ, 2]))R((Subscript[n, 1]),(Subscript[θ, 1])). *)

RotationM//MatrixForm//N (* Numerical approximation of the initial rotation matrix. *)
Rcomposite//MatrixForm//N(* Numerical approximation of the composition of the three derived rotations. *)
Rcomposite-RotationM//MatrixForm//N(* Numerical check if R (n,θ) = R((Subscript[n, 1]),(Subscript[θ, 3]))R((Subscript[n, 2]),(Subscript[θ, 2]))R((Subscript[n, 1]),(Subscript[θ, 1])). *)

Explicit solutins and numerical approximations for (Subscript[δ, 1]), (Subscript[δ, 2]) and the angles (Subscript[θ, 1]), (Subscript[θ, 2]), (Subscript[θ, 3]) (with simplification from Mathematica)

(Subscript[δ, 1])

δ1//Simplify (* Formula 2.38 *)
N[δ1,prec]

(Subscript[δ, 2])

δ2//Simplify (* Formula 2.39 *)
N[δ2,prec]

(Subscript[θ, 1])

θ1//Simplify (* Formula 2.36 *)
N[θ1,prec]

(Subscript[θ, 2])

θ2//Simplify (* Formula 2.40 *)
N[θ2,prec]

(Subscript[θ, 3])

θ3//Simplify  (* Formula 2.37 *)
N[θ3,prec]

Systemized results in a table

Explicit results (with simplification from Mathematica)

Grid[{
{"   R(n,θ) = ","R((Subscript[n, 1]),(Subscript[θ, 1]))","R((Subscript[n, 2]),(Subscript[θ, 2]))","R((Subscript[n, 3]),(Subscript[θ, 3]))"},
{"θ","(Subscript[θ, 1])","(Subscript[θ, 2])","(Subscript[θ, 3])"},
{
 θ//Simplify,θ1//Simplify , θ2//Simplify , θ3//Simplify 
},
{"n","(Subscript[n, 1])","(Subscript[n, 2])","(Subscript[n, 1])"},
{n//Simplify,n1//Simplify,n2//Simplify,n1//Simplify}
},
Frame->All]

Numerical results with 5 digits precision

Grid[{
{"   R(n,θ) = ","R((Subscript[n, 1]),(Subscript[θ, 1]))","R((Subscript[n, 2]),(Subscript[θ, 2]))","R((Subscript[n, 3]),(Subscript[θ, 3]))"},
{"θ","(Subscript[θ, 1])","(Subscript[θ, 2])","(Subscript[θ, 3])"},
{
 N[θ,prec], N[θ1,prec] ,  N[θ2,prec], N[θ3,prec]
},
{"n","(Subscript[n, 1])","(Subscript[n, 2])","(Subscript[n, 1])"},
{N[n,prec],N[n1,prec], N[n2,prec],N[n1,prec]}
},
Frame->All]