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
I've written an article about it that demonstrates how to do it, with source code. The short answer is that you build a 3x3 matrix with the dot products of the different axis