How can I transform a 3D triangle to xy plane Suppose I am given a triangle ABC and its corresponding vertex coordinates in 3D. I want to transform ABC in such a way so that vertex A lies on global  (0,0,0) coordinate, B lies on (dist, 0, 0) where dist is the distance between A to B before transformation and  C lies on the xy plane. 
How can I calculate the transformation for the above case? What would be the rotation and the translation component for such transformation?
 A: First, subtract the coordinates of A from those of all three vertices,
giving the translation (assuming translation is done before rotation --
they don't commute).
This gives vertices (0,0,0), (bx,by,bz) and (cx,cy,cz) as vertices.
Define the vector
u = (bx,by,bz)
pointing from A to B, and normalise it to the unit vector
U = ( 1 /|u|) u  =  ( 1 / √( bx^2 + by^2 + bz^2 ) )  (bx,by,bz) 
Take the cross product 
w = u × (cx,cy,cz),
which is at right angles to the triangle.
Normalise it to give the unit vector
W = ( 1 /|w|) w .
Find the cross-product
V = U  ×W ,
automatically a unit vector.
In coordinates corresponding to the basis {U, V,  W }, the triangle lies as you want. The rotation matrix that carries the usual (1,0,0) to U,  the usual (0,1,0) to V, and the usual (,0,0,1) to W has U, V and W as its columns.  You want the other direction, so take the inverse — which for a rotation matrix is just the transpose. 
This is not "the transformation for the above case", because you did not specify whether C should lie on the y>0 half plane.
