Determination of 2 successive rotations
[qa,angsa,Inok] = CL_rot_defRot2Ax(u,v,axis1,axis2 [,numsol=1]) [qa,angsa,qb,angsb,Inok] = CL_rot_defRot2Ax(u,v,axis1,axis2, numsol=2)
Computes the rotation, combination of 2 rotations around 2 axes, that transforms a vector (u) into another vector (v).
The rotation is returned as a quaternion, and the corresponding rotation angles are also returned.
There are two solutions (in usual situations):
(qa, angsa): solution such that the second rotation angle is minimal.
(qb, angsb): solution such that the second rotation angle is maximal.
axis1 and axis2 can either be vectors (3xN) or axes numbers (1 for x-axis, 2 for y-axis or 3 for z-axis). The axes should be perpendicular to one another. If they are numbers, the vectors u and v must be given in the frame where the axes are basis vectors (coordinates = [1;0;0], [0;1;0], or [0;0;1]).
Indices for which the rotation doesn't exist or is not uniquely defined are returned in Inok.
Notes:
- If no rotation exists, the rotation computed is such that the image of u is as close to v as possible.
- If the axes are given as vectors, the coordinates are those of the vectors not considering the effect of the rotations.
- If the axes are colinear, the results are set to %nan.
Vector to be rotated (3xN or 3x1)
Desired image of u by the rotation (3xN or 3x1)
Axis vector (3xN or 3x1) or axis number (1x1) for the first rotation
Axis vector (3xN or 3x1) or axis number (1x1) for the second rotation
(optional, integer) Number of solutions returned: 1 or 2. Default is 1
Quaternion for the 1st solution (dim N)
Rotation angles for the 1st solution (2xN)
Quaternion for the 2nd solution (dim N)
Rotation angles for the 2nd solution (2xN)
Indices for which the rotation is not uniquely defined, or the desired target vector cannot be reached
CNES - DCT/SB