# Vectors do not define a plane when constructing a RotationMatrix

The following code:

RotationMatrix[{{0, 1, 0}, {0, -1, 0}}]


Gives an assertion message:

RotationMatrix::spln: Vectors {0,1,0} and {0,-1,0} do not define a plane.


Why can I define a RotationMatrix in this way?

Edit I found the reason in here: Calculate Rotation Matrix to align Vector A to Vector B, this is caused by the dot product of two vectors is -1,then the equation is divided by 0.

• Your vectors are colinear, so do not define a unique rotation axis. Jul 22 at 5:47

Edit

Another way is use perturbation.

u = {0, 1, 0};
v = {0, -1, 0};
m = Limit[RotationMatrix[{u, v + t*RandomInteger[20, 3]}], t -> 0]


{{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}}

{{-(87/425), 0, -(416/425)}, {0, -1, 0}, {-(416/425), 0, 87/425}}

etc.

Original

We can find an orthogonal matrix satisfied $$m^{T}\bullet m=\mathrm{Id},\mathrm{Det}(m)=1$$ which transform $$(0,1,0)$$ to $$(0,-1,0)$$

m = Array[a, {3, 3}];
sol = Solve[{Transpose[m] . m == IdentityMatrix[3],
Det[m] == 1, {0, 1, 0} . m == {0, -1, 0}}][[1]];
m /. sol
({0, 1, 0} . m /. sol) == {0, -1, 0}


{{a[1, 1], 0, -Sqrt[1 - a[1, 1]^2]}, {0, -1, 0}, {-Sqrt[1 - a[1, 1]^2], 0, -a[1, 1]}}

True

For example we can set a[1,1]->1/2

{{1/2, 0, -(Sqrt[3]/2)}, {0, -1, 0}, {-(Sqrt[3]/2), 0, -(1/2)}}

• Thanks. It doesn't look like a generic method(maybe I missed your point). e.g. If I want to rotate from{1, 0, 0} to {0, 1, 0} then your method failed. Jul 22 at 3:39
• @ChrisGuo It also work. m = Array[a, {3, 3}]; u = {1, 0, 0}; v = {0, 1, 0}; sol = Solve[{Transpose[m] . m == IdentityMatrix[3], Det[m] == 1, u . m == v}][[1]]; u . (m /. sol ) == v Jul 22 at 3:47
• I still confused. If transforming from {x1,y1,z1} to {x2,y2,z2}, how could you solve the equations for m(it has 9 variables)? Jul 22 at 3:52
• Thanks for the answer, after reading the post in here: link, I think maybe your method is a good workaround for this problem. Jul 22 at 6:04

This situation is another reason why I wrote the vectorRotate[] function in this answer, which implements the method of Möller and Hughes:

vectorRotate[{0, 1, 0}, {0, -1, 0}]
{{-1, 0, 0}, {0, -1, 0}, {0, 0, 1}}