If you need to align two planes, you can obtain the transformation needed (which in general is a roto-translation) using:
or
This allows for instance to superimpose two faces of two meshes like in the following example:
The code to reproduce this example is reported below.
In the first part we create two meshes:
Then we define a transformation that aligns the lower face of mesh2 with the upper face of mesh1.
This can be done in three different ways:
And finally we apply the transformation to mesh2: