Procrustes with dcm2angle: sign error?

1 view (last 30 days)
Christine
Christine on 21 Jan 2014
Answered: AJ von Alt on 21 Jan 2014
Hi!
I have an issue with my script and even when I simplify the numbers, it still looks funny...here's the simplifed form, question still applies.
I am using two arrays which create squares:
original = [ 1 0 1 1 1 1 0 1 1 0 0 1];
rotated = [ 1 0 1 1 0 0 0 0 0 0 0 1];
I use the following commands:
[D, Z, TRANSFORM] = procrustes(rotated, original);
[yawR, pitchR, rollR] = dcm2angle(TRANSFORM.T);
yaw = rad2deg(yawR);
pitch = rad2deg(pitchR);
roll = rad2deg(rollR);
In this case, I correctly find the roll to be -90deg. Right hand rule!
If I swap the two, I would expect to find the roll to be +90 deg. It still comes up as roll = -90deg. Why does it calculate -90deg for roll in either configuration? I see that the original plane could be translated "above" the rotated plane, allowing for a -90 deg rotation, but that is not the objective: I have ensured that the points on the original correspond to the points in the rotated square. That is to say, if I were to leave the adjacent points in place (the first point both the original and rotated are the same and I desire the rotation to be around this point), the shortest roll should be in the positive 90 deg direction, which would bring the far edges of the squares together.
I can add the plots if it is helpful. Understanding this should help me identify the problem in my alignment! Thank you.

Answers (1)

AJ von Alt
AJ von Alt on 21 Jan 2014
The function procrustes allows reflection by default. If you want T to belong to SO(3) you must manually set the 'reflection' flag to false.
You can see that this is happening because the DCM for the transformation from rotated to original has a determinant of -1. (Recall that a 3x3 matrix is a member of SO(3) only if it is orthogonal and has a determinant of 1.)
[D, Z, Tr2d] = procrustes(original,rotated);
det(Tr2d.T)
ans =
-1
roll =
-90
Turning off scaling and reflection fixes this problem.
[D, Z, Tr2oSO3] = procrustes(original ,rotated,'reflection',0,'scaling',0);
det(Tr2oSO3.T)
ans =
1
roll =
90

Community Treasure Hunt

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

Start Hunting!