I am trying to transform a rectangle centered at the origin and dimensions of $(\| P_2 - P_1 \|, 0, \| \mathbf{V_P} \|)$ to a triangle in 3D space with points $P_0$, $P_1$, and $P_2$ where $\mathbf{V_P}$ is the vector perpendicular to the side shared by $P_1$ and $P_2$.
First, I will describe the information I currently know.
Points $P_1$ and $P_2$ are chosen such that their corresponding side, $S_0$, has the maximum length (in the case of an isosceles or equilateral triangle, any of the equal sides of maximum length may be chosen). Choosing this side to be the base ensures that the rectangle will share exactly one side with the triangle.
The coordinate system is right-handed with x to the right, y up, and -z forward.
Before translation, how can I rotate the original rectangle so that the resulting rectangle can be placed on top of the triangle such that the base of the rectangle lies on the maximum side of the triangle, $S_0$, like in the diagram?
I feel like my solution should be somewhat close to the answer in this question, using $x=(0, 1, 0)$ instead, but this does not quite work here.
