Different rotation combinations. First rotate around X-Axis then Z and then vice versa with same results.

522 Views Asked by At

First of all sorry, i am no mathematician and this might be a silly question, but i have the following problem.

I have a Program which rotates a 3D-Object first around the x-Axis or the Y-Axis and then around the z-Axis. The rotations happen via given Axis and Rotationangle in degree.

An other Program now tries to recreate the Object after the rotaions with loading the original Object and rotating it. But it rotates always first around the z-Axis then the y-Axis and then the x-Axis. Again the Rotations are simply defined by the Axis (z,y,x) and the Rotationangle like zRotation 90 = Rotation 90 degree around the z-Axis.

Is there a way to define the needed zRotation, yRotation and xRotation for the second program given the xRotation, yRotation and zRotation from the first Operation?

I tried to simply exchange the rotations which obviously did not work, because then the Object was rotated around the wrong axis.

Any help would be apreciated!

Edit: trueCounter is used to check wheter i have only 1 rotation (so no change is necessary) the xRotation, yRotation and zRotation are the Values for the other Program (whitch always starts with the z-Rotation) and the descr.Rotations are the ones the first Program used.

if (trueCounter > 1)
            {
                if (descr.Rotation_Z == 90)
                {
                    xRotation = (descr.Rotation_Y + 180) % 360;
                    yRotation = descr.Rotation_X;
                }
                else if (descr.Rotation_Z == 180)
                {
                    if (xRotation > 0 && xRotation != 180)
                        xRotation = (descr.Rotation_X + 180) % 360;
                    if (yRotation > 0 && yRotation != 180)
                        yRotation = (descr.Rotation_Y + 180) % 360;
                }
                else if (descr.Rotation_Z == 270)
                {
                    xRotation = descr.Rotation_Y;
                    yRotation = (descr.Rotation_X + 180) % 360;
                }
            }

This seems to work fine for the cases i tested so far, but i am not sure if it will work in all cases. Maybe someone who has a better understanding of it could give me a feedback.