How to find a rotation vector for use in rotate, if the rotation matrix is rank deficient?
A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one.A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one. A couple days ago I made a reddit post asking how to find the rotation matrix for an arbitrary 3D rotation, relative to some global coordinate axis. I got a satisfactory answer; methods can be found on that post and on the wiki page for rotation matrices. I am now trying to implement that into MATLAB and failing.
Let us assume the simple case in that reddit post. The global coordinate axes (xyz) and rotated axes (uvw) are simply
x=[1 0 0];
y=[0 1 0];
z=[0 0 1];
u=[0 1 0];
v=[-1 0 0];
w=[0 0 1];
which represents a +90 degree rotation about the z axis at the origin (0 0 0), but let’s pretend we don’t know that. The hand calcs for this is easy and found on the reddit post. I now try and do the same in MATLAB.
linsolve and lsqminnorm require the B vector to be constants, not with variables. Since B is [x y z], we simply subtract the identity from [u;v;w] and use that as A:
A=[u;v;w]-eye(3)
B=[0;0;0]
Now we have to solve this system of equations. Linsolve and lsqminnorm both return nonsense values:
ls=linsolve(A,B)
lsmn=lsqminnorm(A,B)
From the hand calcs, we know the answer should be [0 0 n] with n being any real nonzero value (preferably 1). What is the appropriate way to resolve this? I have also tried to solve this directly with the rotation matrix given in the wiki, but it returns NaN eigenvectors.
IN ADDITION TO THIS SPECIFIC EXAMPLE
The problem also persists for other orthonormal sets of uvw. I’m getting nonsense values (NaNs) or incorrect values (for example, I’m getting something like 166.5 degrees instead of 90.4 from the hand calc using the reddit example). This indicates I’m having a general problem, not just an edge-case one. rotation, rank deficient, system of equations MATLAB Answers — New Questions









