CL_rot_defQuat — Quaternion definition from its real or imaginary components
[q] = CL_rot_defQuat(r,i1,i2,i3) [q] = CL_rot_defQuat(r,i) [q] = CL_rot_defQuat(ri) [q] = CL_rot_defQuat(ri,str)
real part (1xN)
imaginary part (1xN)
imaginary part (3xN)
real and imaginary part (4xN)
string (use with ri). 'p' -> real part first line (default), 'd' -> real part last line.
q=CL_rot_defQuat(1,[2 3 4]')
q=CL_rot_defQuat([1:4]')
q=CL_rot_defQuat(1,2,3,4)
q=CL_rot_defQuat([1;2;3;4],"p") //real part first column (default)
q=CL_rot_defQuat([2;3;4;1],"d") //real part last column
Defined (overloaded) operations for quaternions:
1) scalar / quaternion:
alpha scalar: q*alpha (same as alpha*q), q/alpha, alpha/q (same as alpha*conj(q) if q is normed)
alpha vector: q.*alpha (same as alpha.*q), q./alpha, alpha./q (same as alpha.*conj(q) if q is normed). (see examples)
2) logical:
q1==q2
3) quaternion / quaternion:
q1*q2 , q1/q2, q1+q2 , q1-q2
4) others:
size(q), norm(q), [q1 q2 ...], conj(q)==~q, real(q), imag(q);
qq=CL_rot_defQuat(rand(4,1000)); // 1000 random quaternions qq=qq./norm(qq); // normalisation size(qq); //Differences between q*alpha, q.*alpha, q/alpha, q./alpha, alpha/q, alpha./q q=CL_rot_defQuat([1 2 3 4;5 6 7 8]') //two quaternions q=q./norm(q); alpha1 = 2; alpha2 = [2 3]; q1 = q*alpha1 //both quaternions are multiplied by 2 q2 = q.*alpha2 //first quaternion is multiplied by 2 while second is multiplied by 3 q3 = q/alpha1 //both quaternions are divided by 2 q4 = q./alpha2 //first quaternion is divided by 2 while second is divided by 3 q5 = alpha1/q //both inverse of q multiplied by 2; alpha1*(inverse of q); inverse of q is 'conj(q)/(q*conj(q))' (equal to conj(q) if q normed); q6 = alpha2./q //first inverse of q is multiplied by 2 while second is multiplied by 3; alpha.*(inverse of q) See 'CelestLab> Demos> ORBITAL_EVENTS> events' for more examples