Rotation Matrix with local control?

87 Views Asked by At

Is there a rotation matrix that provides local control at each axis? I'm not entirely sure how to phrase what I'm asking - the best analogy I can give is imagining taking a physical version of the basis vectors, then literally holding and twisting around one axis, then grabbing and twisting around a second axis (sorry for not being well-versed in linear algebra jargon). Almost like I independently twist the axes themselves, but then somehow combine the results (I also don't want it to be a multistep process - just one matrix, if thats even possible).

All rotation matrices I've found only have that kind of local control at 1 axis, and it's just dependent on the order in which the basis rotation matrices are multiplied. I even tried to derive it myself and got rather close to the behavior I want, but I messed it up and can't trace my error (if you want to see what I did, let me know).

Sorry if this isn't a "good" question, I've just spend the entire day confused with rotation matrices and angles, and wanted to see what actually smart people had to say about it.

EDIT: I found what I was looking for in quaternions, sorry y'all!

1

There are 1 best solutions below

7
On

A good way to have in particular a "fine control" over the axes is to use the exponential formalism.

Precisely, a rotation matrix defined by angle $\theta$ around axis defined by unit vector $\vec{a}=(a_x,a_y,a_z)$ can be expressed in this way :

$$R_{\theta,\vec{a}}=\exp(\theta A)$$

where $A$ is the skew-symmetric matrix

$$A:=\begin{pmatrix}0&-a_z&a_y\\a_z&0&-a_x\\-a_y&a_x&0\end{pmatrix}$$

Of course, you need for your computations to use a software that computes the matrix exponential for you ; Matlab, Python, Mathematica Maple, etc. have a built-in function (matrix) exponential.

This matrix $A$ is often denoted $[a]_{\times}$ because of its connection with cross product $\times$ ; indeed, $[a]_{\times}$ applied to a vector $v$ gives the cross product $a \times v$, as can be seen here :

$$\begin{pmatrix}0&-a_z&a_y\\a_z&0&-a_x\\-a_y&a_x&0\end{pmatrix}\begin{pmatrix}x\\y\\z\end{pmatrix}=\begin{pmatrix}a_yz-a_zy\\a_zx-a_xz\\a_xy-a_yx\end{pmatrix}$$

The fact that cross product is involved in rotation issues shouldn't be a surprise...

By progressive leftwise multiplication (remembering that they do not commute and that all $a_i$ are unit vectors),

$$\cdots R_{\theta_3,\vec{a_3}} \ R_{\theta_2,\vec{a_2} } \ R_{\theta_1,\vec{a_1}}$$

you should be able to "tune" the rotation you desire to achieve.

Here is for example a Matlab code showing the effectiveness of the procedure, knowing that expm and logm are the matrix function exponential and logarithm :

 clear all;
 cro=@(t,a,b,c)(expm(t*([0,-c,b;c,0,-a;-b,a,0]))
 R1=cro(pi/2,1,0,1);
 R2=cro(pi/2,0,1,0);
 R3=cro(-pi/2,1,0,0);
 P=R3*R2*R1;% identical to cro(-pi/2,0,0,1) 
 % which is the pi/2 rot. around z axis ; indeed :
 L=logm(P);
 A=[L(3,2),L(1,3),L(2,1)]; % (non unit) vector giving rotation axis 
 t=norm(A), % rotation angle
 A/t, % (normalized) vector giving rotation axis.