introduction of rotation with quaternions (part 5),version  1.0
peter.vlasschaert@gmail.com, 03/11/2018

solve example :  'simple rotation'
=============

load packages.
=============

kill(all)$
load(vect)$
load(lrats)$
load(functs)$

example : 
========
rotation : α:π/2 about x-axis , point : (0,1,0)

solution :
========

point : given
---------

p1:[0,1,0];

quaternion : representation of point

p1a: j;

rotation matrix  : given
----------------------

a)  Mα matrix : rotation ,about x axes with angle = α 
------------------------------------------------------------------------------

Mα :matrix(
		[1,	0,	0],
		[0,	cos(α),	-sin(α)],
		[0,	sin(α),	cos(α)]);

b)  value α into Mα
----------------------------

Mα:ev(Mα,α=π/2);

c) tracematrix, 'Mα'
---------------------------

TMα:tracematrix(Mα);

find : qα=[q1α,q2α,q3α,q4α]
------------------------------------------

M:matrix(
        [2*q2^2+2*q1^2-1,   2*q2*q3-2*q1*q4,    2*q2*q4+2*q1*q3],
        [2*q1*q4+2*q2*q3,   2*q3^2+2*q1^2-1,    2*q3*q4-2*q1*q2],
        [2*q2*q4-2*q1*q3,   2*q3*q4+2*q1*q2,    2*q4^2+2*q1^2-1]);

q1α:sqrt(TMα+1)/2,radcan;
q2α:sqrt(-TMα+2*Mα[1,1]+1)/2;
q3α:sqrt(-TMα+2*Mα[2,2]+1)/2;
q4α:sqrt(-TMα+2*Mα[3,3]+1)/2;

result : quaternion,conjugate quaternion
--------------------------------------------------------------

a) quaternion
--------------------

qα:[q1α,q2α,q3α,q4α];

b) conjugate quaternion
------------------------------------

cqa:[q1α,-q2α,-q3α,-q4α];

rem : cos(α/2) = sin(α/2) = 1/sqrt(2)  => α = π/4
-------------------------------------------------------------------

same with : angle = α, Mα  =>

α:π/2;

a) quaternion
--------------------

p3:qαα=i*sin(α/2)+cos(α/2);

b) conjugate quaternion
------------------------------------

p3a:cqαα=-i*sin(α/2)+cos(α/2);

result : qar=qαα.p1.cqαα  'FORMULA'
===============================

rules : multiplication of quaternions
==============================

p4:[i.j=k,j.k=i,k.i=j,j.i=-k,k.j=-i,i.k=-j,i.i=-1,j.j=-1,k.k=-1];

multiplication
===========

qar1:subst(p4,expand(rhs(p3).p1a));

qar:subst(p4,expand(qar1.rhs(p3a)));

total result ( point rotation)
======================

 (0,1,0)  => (0,0,1),  j=> k   

----------------------------------------------------------------------------------
pure quaternion =  quaternion with real part =0 = vector
----------------------------------------------------------------------------------

'-----------------------------------------------------------------------------------------------------------------------------------------------------------'