$LastChangedDate: 27-Juil-2011 $

# CL_rot_defQuat

Quaternion definition from real and 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,order)

## Description

- Returns a quaternion defined by its real or imaginary components.

  The quaternions components may be defined in several ways:

  - real part (r) and imaginary part (i1,i2,i3) = 4 arguments.

  - real part (r) and imaginary part (i) = 2 arguments.

  - real and imaginary part (ri) = 1 argument.

  - real and imaginary part (ri) + order = 2 arguments. The order helps determine the position of the real part in the 4-component vector.

  => order = "ri": the input vector corresponds to [r,i1,i2,i3] (real part first).

  => order = "ir": the input vector corresponds to [i1,i2,i3,r] (real part last).

- Examples:

  All the following calls return the same quaternion:

  q = CL_rot_defQuat(1, 2, 3, 4)

  q = CL_rot_defQuat(1, [2; 3; 4])

  q = CL_rot_defQuat([1; 2; 3; 4])

  q = CL_rot_defQuat([1; 2; 3; 4], "ri" ) // (real part first)

  q = CL_rot_defQuat([2; 3; 4; 1], "ir" ) // (real part last)

- Notes:

  - The quaternion as defined is NOT normalized.

## Parameters

r, i1, i2, i3 :

  Real and Imaginary components (1xN)

r, i :

  Real part (1xN) and Imaginary part (3xN)

ri :

  Real and imaginary part (4xN)

ri, order :

  Real and imaginary part (4xN) and order ('ri' or 'ir' : see above).

q :

  Quaternion (dim N)

## Authors

- CNES - DCT/SB

## Examples

    // 1000 random quaternions :
    q = CL_rot_defQuat(rand(4,1000));