Rotation Matrix to RPY

mathnab

New member
Joined
Aug 27, 2012
Messages
5
Hello,
I came across a problem while programming with objects.
I can let objects rotate by giving them RPY-Angles (first rotation is around the fixed Y-Axis, second around fixed Z and third around fixed X).
Now I want to have the corresponding angles (RPY) to rotate an object 90 degrees (to simplify) about an arbitrary axis n.
I'm new to this topic and have already tried searching for solutions, but it won't work (probably because I just used random formulas).
It would be great if I could get some help with this problem, thanks.
 
Hello,
I came across a problem while programming with objects.
I can let objects rotate by giving them RPY-Angles (first rotation is around the fixed Y-Axis, second around fixed Z and third around fixed X).
Now I want to have the corresponding angles (RPY) to rotate an object 90 degrees (to simplify) about an arbitrary axis n.
I'm new to this topic and have already tried searching for solutions, but it won't work (probably because I just used random formulas).
It would be great if I could get some help with this problem, thanks.

Is it a small rotation (<4°) or large rotation?

For small rotation, you can break-up the (arbitrary) axis of rotation into three orthogonal axes and add those up vectorially.

Large rotation would become a different issue...
 
it's a large rotation
I was thinking i could just find the angles to the 90 degree rotation and then multiply them to have a larger rotation.
Would your approximation work in that way?
 
it's a large rotation
I was thinking i could just find the angles to the 90 degree rotation and then multiply them to have a larger rotation.
Would your approximation work in that way?

No - you would need matrix multiplication (tensorial transformation) for those. You need to talk to a university level applied math or physics professor. I do not have enough time to walk you through that.
 
Ok, well this is the last big problem I'm facing and I can't continue if I don't get this solved.
Is there anyone that can help me here?
 
The simplest way to do this is to find the eigenvalues of the rotation matrix. Because this is a 3 by 3 rotation matrix two of its eigenvalues are complex and the third pure real. The eigenvector corresponding to the real eigenvalue points in the direction of axis of rotation. You can find the angles that vector makes with the x, y, and z axes.
 
I don't know the matrix.
This one is taken from the german wiki page for the rotation about a normed vector n.

b5aee9238d59bc53c5b798829bdfa583.jpg

Could I use this one in my case?
 
Yes, you can. And since you are only interested in a 90 degree rotation, and cos(90)= 0 and sin(90)= 1, you can use the matrix
\(\displaystyle \begin{bmatrix}n_1^2 & n_1n_2- n_3 & n_2 \\ n_1n_2+ n_3 & n_2^2 & n_2n_3- n_1 \\ n_1n_3- n_2 & n_2n_3+ n_1 & n_3^2\end{bmatrix}\) where \(\displaystyle n_1\), \(\displaystyle n_2\), \(\displaystyle n_3\) are the components of a unit vector in the direction of the axis of rotation.
 
well, I'd still need the rpy values.

Anyways, I came up with another solution, so this is only for anyone that is interested:

I came across this problem while trying to write a physics script for cubes.
So the orthogonal vector that the cube should be rotating around is the vector product of the reflection vector when bouncing off a wall and the wallnormal.
In code:

vel: object's velocity before collision

//reflection vector
v = vel + vectordot( wallnormal, vel ) * wallnormal * -2;

//orthogonal vector the object should rotate about
n = vectornormalize( vectorprod( v, wallnormal ) );

Now with the object having angles=(0,0,0) the way it should be rotated (in rpy) is:

angles = ( n[1]*-1, n[2]*-1, n[0]*-1 );

To have it work in any direciton my thinking was: rotate the orthogonal vector n about the z-axis for object-angle-y-degrees
and do the same for the other axes.
In code:

n = rotatevec_z( n, object.angles[1]*-1 );

//buggy after other rotations
//n = rotatevec_y( n, object.angles[0]*-1 );
//n = rotatevec_x( n, object.angles[2]*-1 );

The vector n got messed up after rotating it about the y and x axis, still it is good enough with only the z axis.
Although I do wonder why it gets so messed up after the y and x rotation.
It showed values like (200,60,0) even though it should be a normed vector.
 
Top