introduction of rotation with quaternions (part 1),version  1.0
peter.vlasschaert@gmail.com, 25/10/2018

load packages.

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

see also : website , topics about rotation ( around different axis).

complex number : q = a+b*i+c*j+d*k ( when c=0,d=0, i^2 =-1)
==================================================
maxima :  z = a+%i *b, complex number
rem :  q =quaternion

e^(i*θ) , math : example : e^(i*π) = -1
------------------------------------------------------

p1: exp(%i*θ);

Menu : Simplify : Complex Simplification : Demoivre

p2:demoivre(%e^(%i*θ));

p3:p1=p2;

rem :  %e =2,7....  number

p3a:float(%e);

Complex multiplication : ' rotation of a vector '
---------------------------------------------------------------------

  z = x+i*y , complex number
 -----------------------------------------

p4: z= x+y*%i;

p5:rhs(p4)*p3;

p6:lhs(p5) = expand(rhs(p5));

RE :  real  part , ' p6'
-----------------------------

p7a:xp=subst([%i=0],rhs(p6));

Menu : Complex Simplification : Get Real Part

p7a1:lhs(p7a) = realpart(rhs(p6));

IM : imaginary part, 'p6'
----------------------------------

p7b:yp=ratcoef(rhs(p6),%i);

Menu : Complex Simplification : Get Imaginary Part

p7b1:lhs(p7b) = imagpart(rhs(p6));

rem : (-1)  ,with respect to math : 'see p7a'

result : (r)otation matrix  = R(θ)
==========================

p8:(-1)*coefmatrix([p7a,p7b],[x,y]);

Why : property : determinant = 1

check : 
-----------

<================================>

p8a:determinant(p8);

p8b:trigsimp(p8a);

<================================>

Menu : Algebra : Enter Matrix 'p9,p9a'

p9:matrix(
 [xp], 
 [yp]
);

p9a:matrix(
 [x], 
 [y]
);

transformation matrix 'p8': (x,y)  => (xp,yp)
====================================

p9b:p9 = p8.p9a;

multiplication : two complex numbers {z1,z2}
======================================

 z  = z1*z2 = c*i+d
===============

---------------------------------------------------------------
z1 = a1+b1*i    : 'first complex        number'
z2 = a2+b2*i    : 'second complex number'
---------------------------------------------------------------

p10:    z1=b1*%i+a1;
p10a:  z2=b2*%i+a2;

p10b:p10*p10a;

p10c:z=expand(rhs(p10b));

see 'above' , why

p10d : lhs(p10c) = c*%i + d;

find : c,d
-------------

p11: rhs(p10d) = rhs(p10c);

d  'real-part (z)'
============

p11a:realpart(p11);

c  'imag-part (z)'
=============

p11b:imagpart(p11);

how to convert 
-----------------------
  z1 =a1*i+b1  => matrix representation.
                               ==================

p12:(-1)*coefmatrix([p11a,p11b],[a2,b2]);

 z = z(c,d) , result  'complex number'
------------------------------------------------------

p12a:matrix(
 [d], 
 [c]
);

z2=z2(a2,b2)
--------------------

p12b:matrix(
 [a2], 
 [b2]
);

p12c:p12a=p12.p12b;

we show : 'p12c '  = 'p11a' and 'p11b', result : matrix representation must be true.

find: % i  = > math  i^2=-1 => i =sqrt(-1)
---------------------------------------------------------

a)   unity matrix (2 by 2).
-------------------------------------

zero matrix
-----------------

p13: zeromatrix(2,2);

unit matrix
----------------

1e ) method : input

Menu : Algebra : Rows       => 2 
                                Columns =>  2
                                type          => diagonal
                                name        => m
                                Ok

m: matrix(
 [1,0], 
 [0,1]
);

2e) method : build in function maxima

representation of one in matrix form

p14:ident(2);

value :

p14a:determinant(p14);

b)  find  'i' representation .
---------------------------------------

rem : m[i,j] : other values. ; m[1,1] : 1,m[2,2] : 1, diagonal elements

see :  'p12'  representation  z1=a1+b1*i

p15 :p12;

to find  i: ?   a1=0,b1=1
-----------------------------------

p15a:%i = lratsubst([a1=0,b1=1],p15);

=>  find  %i representation  matrix. ' imaginary part matrix '

p15a1: rhs(p15a);

check : i^2= -1

p15b:(lhs(p15a))^2=rhs(p15a).rhs(p15a);

matrix representation : complex number 
==================================

 z1= a1*1+b1*i  , 1 = unit matrix, %i = 'p15a'

p16:subst([a1=1,b1=1],p15);

=>  find  1 representation  matrix. ' real part matrix '

p17:p16-rhs(p15a) ;

result : 
=====

no eval :  use dot '.' ,(formula)
----------------------------

p18:z1=a1.''p17+b1.''p15a1 ;

eval  : use regular '*'
------------------------------

p18a:lhs(p18) = a1*''p17+b1*''p15a1;

we get same result : back  ' p15 '

i : representation ' matrix'
---------------------------------------

p18b :p15a;

rem :    i = math notation      = sqrt(-1)
          %i = maxima notation = sqrt(-1) 

---------------------------------------------------------------------------------------------------------------------------