I have two identical mesh objects, but their positions and rotation directions are different; I know the position information of the two mesh vertices, how can I get the relative transformation matrix between them

I have two identical mesh objects, but their positions and rotation directions are different; I know the position information of the two mesh vertices, how can I get the relative transformation matrix between them

obtain or construct homogenuous transform matrix for each object
lets call them a,b corresponding to meshes A,B
compute the difference matrix d
for example you want to go from A to B then its just matter of solving:
a*d = b
Inverse(a)*a*d = Inverse(a)*b
d = Inverse(a)*b
Beware in case you use different notations (like reverse order of multiplication and or inverse matrices instead of direct ones the equation might get inverted and or transposed)
Also here another example: