How to rotate cuboid to plane I have a cuboid with 8 points that is axis aligned with its center at the origin 0,0,0. Now I have a plane and want my cuboid to rotate so that instead of being axis aligned, it is now aligned to this plane and its front and back side are parallel to the plane and the center is on the plane.
However, I also want to get the euler angles for this rotation so I can manually change the result. It needs to be euler angles and not a matrix/quaternion so the values can be changed by the user and euler angles are the best way for this representation.
I tried some ways to do this, but it never accurately worked.
 A: Compute three vectors $X$, $Y$, $Z$ representing your new coordinate frame
as you describe it. $Z$ would be the normal to your plane, and $X$ and $Y$ are
determined by your "its front and back side are parallel."
Then follow the description in Wikipedia, Geometric derivation,
which details the computation of the Euler angles from $\{X,Y,Z\}$.

          


          

(Image from Wikipedia.)


A: See my answer here: https://math.stackexchange.com/a/1217362/3301
Find the two rotation angles α and β for the given plane using the link above and then apply the rotation to all the nodes in the mesh.

The direction of the plane is described as two rotations about the X and Y axis. The details I think are as follows:
$$\left. \frac{(a,b,c)}{|(a,b,c)|} = {\rm RY}(\alpha) {\rm RX}(-\beta) \hat{k} \right\} $$
$$ \begin{align}
\frac{a}{\sqrt{a^2+b^2+c^2}} &= \sin(\alpha)\cos(\beta) \\ 
  \frac{b}{\sqrt{a^2+b^2+c^2}} &= \sin(\beta) \\
  \frac{c}{\sqrt{a^2+b^2+c^2}}&= \cos(\alpha)\cos(\beta) \end{align}$$
The above is solved for $\sin(\beta)$ from the 2nd equation, and for $\cos(\beta)$ by squaring and adding the 1st and 3rd equation. 
$$ \frac{a^2+b^2}{a^2+b^2+c^2} = \cos^2(\beta) $$
Then $\cos(\beta)$ is substituted into the 1st and 3rd equation to be solved for $\sin(\alpha)$ and $\cos(\alpha)$

