$LastChangedDate: 27-Juil-2011 $

# CL_rot_defFrameVec

Frame definition based on 2 vectors.

## Calling Sequence

       [M,Inok] = CL_rot_defFrameVec(u, v, n1, n2 [,res='m'] [,meth])
       [q,Inok] = CL_rot_defFrameVec(u, v, n1, n2, res='q' [,meth])

## Description

- This function defines a new frame based on 2 vectors.

  Considering two vectors u and v, the new frame basis vectors are such that:

  - n1 axis: aligned with u (and same direction)

  - n2 axis: in the half-plane delimited by u and containing v.

- If u and v are (nearly) aligned or if n1 and n2 are identical, the basis vectors are such that:

  - n1 axis: aligned with u (and same direction)

  - other axes: perpendicular to n1 axis (arbitrary directions).

- - Inok contains the indices for which the new frame is not uniquely defined.

  - CL_rot_defFrameVec(u,[],n1,[]) is equivalent to: CL_rot_defFrameVec(u,u,n1,n1).

## Parameters

u:

  First vector (3xN or 3x1)

v:

  Second vector (3xN or 3x1)

n1:

  First axis number (axis colinear with u). Possibles values are: 1, 2 or 3 (1x1)

n2:

  Second axis number (axis in the (u,v) plane). Possibles values are: 1, 2, 3 (1x1)

res:

  (optional, string) Type of result: 'm': frame transformation matrix, q: rotation quaternion. Default is 'm'

meth:

  (optional, string) Method used: 'm': Method based on matrices (faster), 'q': method based on quaternions (result consistent with CL_rot_defRotVec). Default is 'm'

M/q:

  Frame transformation matrix (3x3xN) or rotation quaternion (dim N)

Inok:

  Indices for which the new frame is not uniquely defined.

## Authors

- CNES - DCT/SB

## See also

- CL_rot_defRotVec

## Examples

    CL_rot_defFrameVec([1;0;0], [1;1;0], 1, 2) // => identity

    // Computes local orbital frame:
    kep = [7000.e3; 0.01; %pi/3 ; 0 ; 0; 0]; // orbital elements
    [r,v] = CL_oe_kep2car(kep); // position and velocity

    M = CL_rot_defFrameVec(r, v, 1, 2) // => "qsw" local frame
    q = CL_rot_defFrameVec(-r, v, 3, 1, res='q')  //=> "lvlh" local frame