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

3dgeometry

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.

My extruded and rotated graphic, indicating the side whose angles I want to calculate

What I know about the transformations applied to the original graphic.

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?

Best Answer

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°

Related Question