# Rotation matrix between two objects - alignment

I am trying to align two objects based on the notion of points and their correspondence, but struggling to find a solution.

I have two objects A and B. However, they are rotated in a different direction, and therefore I would like them to align. I have a notion of some correspondence between the points in object A and in object B.

The initial idea that I had looks as follows. Pick two points( let's call them center and end point) in A, and then pick the corresponding points in B. Then measure the angle between them.

I believe that I could get an angle between them, but I am not sure how would that translate to the rotation matrix. I was also wondering whether it is not better to split it into different axes , and then perform multiplication. However, I am not sure how would I proceed with that.

Could anybody give me advice whether my approach is ok, or possibly provide a way of obtaining a rotation matrix for the whole object based on those vectors?

My idea:

Let's say that I have object A, and two points:

A0 = [2,4,6]

A1 = [3,5,7]

Then I calculate a vector

A0A1 = [1,1,1]

Then I find a corresponding two points in object B:

B0 = [4,8,12]

B1 = [2,7,5]

Then B0B1 = [-2,-1,-7]

Now I would calculate the angle

$$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$.