Rotation matrix between two objects - alignment
You probably want to find a homography that maps object A to object B.  I suggest reading about image rectification/alignment/registration.  A homography is a linear function of the form

$$q = Ap+b,$$

where $A$ is a matrix, $b$ is a translation vector, $p$ is a point from object $A$, and $q$ is the corresponding point from object $B$.

If you have four points from object A and the corresponding four points in B, you can solve uniquely for a homography that maps each of those A-points to the corresponding B-point (using linear algebra).  There are standard methods for finding that homography in the computer vision literature, based on solving a system of linear equations.  For instance, OpenCV has a method that will do that for you.

More generally, if your points have some small amount of error in them, it can be more effective to take more than four points and then find the best-fit homography.  For instance, you could take five points, or six points, or 10 points, and find the best-fit homography that maps those 10 points from object A (as close as possible) to the corresponding 10 points from object B.  This becomes a least-squares fit problem, where you want to minimize the sum of the squared distances between (homography applied to point from object A) and (location of corresponding point in object B).  There are ways to find that best-fit homography using a least-squares fit.

There's lots more one can say about the subject -- it has been studied extensively in the image processing and computer vision literature. See https://en.wikipedia.org/wiki/Point_set_registration for a starting point.