1
votes

I have an 3D object in 3D space oriented in some orientation. How can I know it has been rotated from its initial rotation q (in euler angles: 0, 0, 0) only in arbitrary number of 15 degree rotations in any axis. E.g, rotated in X-axis 4*15 degrees, and in Y-axis 7*15 degrees and in Z-axis 13*15 degrees. How can I detect this?

I have tried to take euler angles from the object's rotation matrix but it seems to detect the situation correctly only if I rotate only in one axis. If I start to mix X,Y and Z axis 15 degree rotations, the euler angles gets messed up.

I am 100% sure that the object has been rotated only in 15 degree chunks.

4
I'm pretty sure that any rotation matrix is arbitrarily close to a product of 15° rotations along coordinate axes. Could you provide some background on the question so that we can guide you towards a different path ?Alexandre C.
no it isn't. 360 is dividable by 15.iosiki
@iosiki: It doesn't matter. If you rotate 15°X, then 15°Y, then 15°Z, you get a rotation which is neither around X nor Y nor Z. Let us call this rotation XYZ. Now I state that if you take any rotation, there is a "word" (eg. XXYZYYZYXYYZ) which is arbitrarily close to it. Actually, I'm pretty sure my statement is true, and this is akin to the argument which yields the Banach-Tarski paradox. As you say, in 2D this would be false.Alexandre C.
@ioski: If you can find two words (say A=XYZ and B=XZY, which should probably work) which represent two rotations with irrational angle around two independent axes, then my statement is true (see irregularwebcomic.net/2339.html for instance)Alexandre C.
We get to the start rotation by doing 24*X (24*15 = 360), and by doing 24*Y and by doing 24*Z. Shouldn't we get to to start rotation by doing 24*X + 24*Y + 24*Z in any arbitrary order too? Now, I want to detect if an arbitrary rotation can be formed by that formula.iosiki

4 Answers

0
votes

Rotation matrices can only be decomposed into quaternions, I believe, and cannot be decomposed into per-axis rotations.

0
votes

I am not sure what math library you are using, but, if provided, you could use quaternions, which will quite straightforward the functionality you want. They can be translated to rotation matrices afterwards.

0
votes

Rotations are not commutative, therefore describing them with Euler angles is problematic if you don't know the right order. If you know the order, you can set up an equation system with a multiplication of three rotation matrices (parameterized by the rotation angle) on one side and the final rotation matrix on the other side. Gives you three equations and three unknowns. But watch out for singularities in Euler angle representation!

0
votes

If you can, the dead simplest way is to store both the components (float3 m_Translation, m_Rotation, m_Scale) and a matrix that is updated whenever they change (float4x4 m_Matrix). To get the data out, simply grab the vector for that part and return it. The memory use is small (12-16 floats) and computational overhead is minimal (recalculate the matrix when a part is updated).

However, if that can't be done, Google suggests you can decompose rotation matrices with a bit of work like so. It does take a chunk of math.

As noted in that page, the D3DX libraries also have a function to decompose matrices: D3DXMatrixDecompose.