# How to Find the Rotation Matrix?

87 views (last 30 days)
ercan duzgun on 1 Feb 2021
Commented: ercan duzgun on 2 Feb 2021
What is the possible solutions for an \$3x3\$ size orthogonal matrix with the known parameters of the first two columns which makes 6 parameters known?
Let's think of a rotation matrix which is an orthogonal matrix:
R=[r11 r12 r13;
r21 r22 r23;
r31 r32 r33]
The parameters of r11, r21, r31, r12, r22, r32 are known values. And it is desired to find the last (third) column with the parameters of r13,r23,r33.
I take the square root of each raw which is equivalent to 1 unit vector.\
r11^2+r12^2+r13^2=1
r21^2+r22^2+r23^2=1
r31^2+r32^2+r33^2=1
Therefore we can get to the equations of
r13= sqrt(1-r11^2-r12^2)
r23= sqrt(1-r21^2-r22^2)
r33= sqrt(1-r31^2-r32^2)
However, if there is one solution for the rotation matrix of R, how can I find that unique solution. Square root of any raw gives me two solutions.
Whichever (positive/negative square root of r13,r23,r33 I would take, it would be still an orthogonal matrix:
r1^2+r23^2+r33^2=1
So is there one unique solution or multiple solutions?

David Goodmanson on 1 Feb 2021
Edited: David Goodmanson on 2 Feb 2021
Hi ercan,
MODIFIED
First of all, for a rotation matrix the two known columns have to be an orthonormal pair, meaning that there are conditions on the initial six variables. If these variables are relabeled as two 3x1 column vectors c1,c2 then
norm(c1) = norm(c2) = 1; dot(c1,c2) = 0
Let's assume that's true.
From your eqns, at first glance it might seem that there could be eight solutions, since you can have +-1 for each of r13,r23,r33. However, the rows have to be orthogonal, so e.g.
r11*r21 + r12*r22 + r13*r23 = 0
If you have a solution, then changing one of r13 or r23 will change the sign of the last term and will not provide a solution. You can change both signs or neither, but not just one. Similarly for the other pairs of rows. The net result is that there are two solutions. One solution is third column equaling the cross product of the first two columns (thus being perpendicular to both of them), and the other solution is simply that solution times an overall minus sign.
However, changing the overall sign in the third column also changes the sign of the determinant of the matrix. As Bruno pointed out, a rotation matrix must have determinant +1. So the only solution is
c3 = cross(c1,c2)
in which case
R = [c1 c2 cross(c1,c2)]
has determinant +1.
Note that for this to come out correctly there is a sign convention present (or one might say, hidden) in the cross function.
David Goodmanson on 2 Feb 2021
Hi ercan,
What I meant by 'similarly for the other pairs of rows' is that what is true for rows 1 and 2 is also true for rows 1 and 3
r11*r31 + r12*r32 + r13*r33 = 0
so by the same argument you can change either neither or both signs of r13,r33, but not just one sign. Combining that with the result for r13,r23 means that all three signs have to change simlutaneously.

Bruno Luong on 1 Feb 2021
You equation is NOT enough to determine the third column, you forget about the orthogonal conditions and that det(R)=1 (rotation matrix is SO(3)).
So solutions is simply
R(:,3) = cross(R(:,1),R(:,2))
ercan duzgun on 2 Feb 2021
Thank you @David Goodmanson , thank you @Bruno Luong .

R2019b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!