Name

CL_rot_defQuat — Quaternion definition from its real or imaginary components

Calling Sequence

   [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)
   
   

Parameters

r:

real part (1xN)

i1,i2,i3:

imaginary part (1xN)

i:

imaginary part (3xN)

ri:

real and imaginary part (4xN)

str:

string (use with ri). 'p' -> real part first line (default), 'd' -> real part last line.

Description

  • Returns a quaternion given its real or imaginary components. Output quaternions are NOT normed. All these operations define the same quaternion:

    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);

  • To access real and imaginary parts of a quaternion, you can use q.r and q.i or real(q) and imag(q).
  • Applications with normed quaternions: An attitude quaternion is defined by the rotation (alpha around u) of the satellite going from reference (J2000 for instance) to its actual attitude, where alpha is a simple rotation angle and cos(beta_x), cos(beta_y) and cos(beta_z) are the "direction cosines" locating the axis of rotation u (Euler's Theorem).

  • Last update : 27/6/2008

Authors

CNES - DCT/SB

See also

CL_rot_matrix2quat, CL_rot_quat2matrix, CL_rot_rotVect

Examples

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