$LastChangedDate: 27-Juil-2011 $

# CL_rot_defRot1Ax

Determination of a rotation around one axis.

## Calling Sequence

       [qa, anga, Inok] = CL_rot_defRot1Ax(u, axis, d, target_ang, [numsol=1] )
       [qa, anga, qb, angb, Inok] = CL_rot_defRot1Ax(u, axis, d,  target_ang, numsol=2)

## Description

- Computes the rotation around one axis so that the angle between the image of a vector (u) and a vector d is equal to target_ang.

  That is to say, the rotation R is such that: R(u)=v and angle(v,d)=target_ang. There can be 2 solutions (in usual situations).

  Each rotation is returned as a quaternion, and the corresponding rotation angle is also returned.

  If the condition "angle(v,d)=target_ang" cannot be achieved, the returned rotations are identical and they are computed such that "|angle(v,d)-target_ang|" is minimal. The corresponding indices are returned in Inok.

  When 2 solutions exist:

  qa is the solution with minimal rotation angle.

  qb is the solution with maximal rotation angle.

  The argument axis can either be a vector (3xN) or an axis number (1=x,2=y or 3=z) (1x1). If it is a number, the vectors u and d must be given in the frame where the axis is one of the basis vectors (coordinates = [1;0;0], [0;1;0], or [0;0;1]).

## Parameters

u:

  Vector to be rotated (3xN or 3x1)

axis:

  Axis: vector (3xN or 3x1) or number (1x1)

d:

  Some direction (3xN or 3x1)

target_ang:

  (optional) Desired angle between d and the image of u by the rotation (1xN or 1x1)

numsol:

  (optional, integer) Number of solutions returned: 1 or 2. Default is 1

qa:

  Quaternion that defines the rotation (first solution) (dim N)

anga:

  Rotation angle (first solution) (1xN)

qb:

  Quaternion that defines the rotation (second solution) (dim N)

angb:

  Rotation angle (second solution) (1xN)

Inok:

  Indices for which the desired angle between d and the image of u by the rotation cannot be achieved.

## Authors

- CNES - DCT/SB

## See also

- CL_rot_defQuat

- CL_rot_defRotVec

- CL_rot_defRot2Ax

## Examples

    // Example1: Rotation about x-axis that transforms
    // u into a vector perpendicular to d
    u = [ 1 ; 2 ; 3 ];
    d = [ 3 ; 1 ; 2 ];
    [q, ang, Inok] = CL_rot_defRot1Ax(u, 1, d, %pi/2);
    // Check result :
    v = CL_rot_rotVect(q,u);
    CL_vectAngle(v,d)  // == %pi/2

    // Example2: Rotation about an axis that transforms u
    // into a vector as close as possible to d
    u = [ 1 ; 2 ; 3 ];
    d = [ 3 ; 1 ; 2 ];
    axis = [-2;3;4];
    [q, ang, Inok] = CL_rot_defRot1Ax(u, axis, d, 0);
    // Check result :
    ang = CL_vectAngle(d,CL_rot_rotVect(q,u))
    angmin_approx = min(CL_vectAngle(d,CL_rot_rotVect( ..
    CL_rot_axAng2quat(axis,linspace(0,2*%pi,200)),u)))