There are two coordinate systems. We know the 3D coordinates of the origin and the 3D vectors of the axes of the second coordinate system with respect to the first coordinates s
Let A be the 4x4 matrix defining the relationship between the two coordinate systems.
Then the angle between the two is:
θ = arcos(trace(A)/2.0)