Search code examples
matlabrotationcode-snippetseuler-anglesrotational-matrices

Rodrigues formula not accurate?


Is the Rodrigues formula only valid for small angles?

I tried to rotate a vector (1,0,0) around the y-axis first and then around the z-axis using the Rodrigues formula from wikipedia (https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula).

The first rotation of 10 degrees around y-axis seems to be ok (v_r1 = 0.984807753012208 0 -0.173648177666930). But if I rotate v_r1 10 degrees around the z-axis, then I would assume that the y and z component of v_r2 would be the same. This is the case for small alpha and beta angles.

But try to increase alpha and beta to e.g. 60 degrees. Then v_r2 makes no sense any more.

This makes me think: Is the Rodrigues formula only valid for small angles? And is the Rodrigues formula actually accurate or only an assumption?

You can copy and paste the following code directly in your matlab command window in order to see what I mean:

alpha = deg2rad(10);
beta = deg2rad(10);

% origin vector:
v = [1;0;0];

% 1: rotate vector around y-axis:
y_axis = [0;1;0];
c1 = cross(y_axis,v); %cross product between rotation axis and vector
v_r1 = v.*cos(alpha)+(c1)*sin(alpha)+y_axis.*(y_axis.*v)*(1-cos(alpha));

% 2: rotate vector around z-axis:
z_axis = [0;0;1];
c2 = cross(z_axis,v_r1);
v_r2 = v_r1.*cos(beta)+(c2)*sin(beta)+z_axis.*(z_axis.*v_r1)*(1-cos(beta));

vector_length = sqrt((v_r2(1)^2)+(v_r2(2)^2)+(v_r2(3)^2));

Thank you.


Solution

  • Rotations in 3D are not commutative. Your intuition that the y and z components should be the same is not correct. In the small-angle limit, the non-commutativity is small.

    Think about your x-oriented vector and doing 90 degree rotations. Rotating about y gives something that's parallel to z, and then rotating around z doesn't change the vector, so you get something parallel to z. Doing it the other way around, the first 90 degree rotation about z gives something parallel to y, and then rotating around y doesn't affect it. So you've got something parallel to z in one order and something parallel to y for the other order.