# Calculating the rotations necessary to make a 2D object match the perspective of a plane in 3D space

I'm working with 3D rotations and extrusions in Adobe Illustrator. I have a square that I have extruded into a rectangular prism, which I've then rotated a known amount (x°, y°, z°) on each axis. I'm not using perspective, so I assume that makes the result some kind of axonometric projection (probably isometric?).

I have another 2D object that I want to also rotate in 3D space so that the perspective matches that of one of the other five sides of the original extruded cube.

Given what I know, it seems like I should be able to calculate the transformations needed on the new object. But various sensible-seeming combinations of simply adding 90° to/subtracting 90° from/inverting the sign of the old values don't seem to generate what I need.

So: Just how complicated is the math I need to do this?

-
A few disclaimers: Yes, I'm in way over my head on the math. Yes, I know that Illustrator and Photoshop have easier ways to do this without doing math. I don't care; I want to know how to do it properly for my personal enrichment. It's possible that I simply didn't do the right combination of simple math on the original angles; sorry if that's the case. Yes, I know that my title sucks and that I may not have used the right words about stuff like the kind of projection being used. Please feel free to edit my question to be more coherent and discoverable. – 75th Trombone Jun 26 '12 at 4:32

Composition of Euler angles is not simple.

1. Convert your Euler-angles to rotation matrices, and multiply them together.

R1 = rotate 90° around y-axis — Rotates to left side
R2 = rotate 14° around x-axis
R3 = rotate -14° around y-axis
R4 = rotate -32° around z-axis
R = R4 × R3 × R2 × R1

2. Recover the angles

x' = arctan2(R3,2,R3,3) = arctan2(cos(y)·sin(x), -sin(y))
y' = -arcsin(R3,1) = -arcsin(cos(y)·cos(x))
z' = arctan2(R2,1,R1,1) = arctan2(cos(z)·sin(x) - sin(z)·sin(y)·cos(x), -sin(z)·sin(x) - cos(z)·sin(y)·cos(x))

In your specific case, this evaluates to:

x' = 44.1°
y' = 70.3°
z' = 13.9°

-