There are too many matrixs satisfy the equation M.u==v
.
Without loss general, we can Normalize
the vector u
and v
.
Besides the RotationMatrix
which have mention by @Daniel Huber, we can construct the reflect-matrix by hand which also satisfiy the equation M.u==v
u = Normalize[{x, y, z}, Sqrt[#.#] &];
v = Normalize[{a, b, c}, Sqrt[#.#] &];
normal = Normalize[u - v, Sqrt[#.#] &];
M = IdentityMatrix[3] - 2 Outer[Times, normal, normal];
M.u == v // Simplify
True
ReflectionMatrix
maybe another choise.
u = Normalize[{x, y, z}, Sqrt[#.#] &];
v = Normalize[{a, b, c}, Sqrt[#.#] &];
normal = Normalize[u - v, Sqrt[#.#] &];
M = Simplify[ReflectionMatrix[normal], normal ∈ Reals];
M.u == v // Simplify
True
For difference dimensions vector u and v,we can also combine the matrixs such as projection matirx and reflection matrix and rotation matirx to construct such matrix.