3D rotation mismatch calculation

I am trying to figure out a way to compare the 3D rotation of two objects and find a measure of HOW MUCH they are mismatched. The only thing I have is I have the two objects’ matrices or quaternions. Is there some way to say how much their rotations differ?

The reason I need it is because I’m comparing two methods to rotate 3D objects and experiment participants have to rotate an object to match a target. i.e. I need a way to quantify the mismatch.

Any advice would be appreciated.

Jubei

I may be missing something, but think about it this way:

  1. You have a rotation R1 from a base orientation O to rotated orientation A (gold standard)
  2. You also have a rotation R2 from the base orientation O to a rotated orientation B

You want to find out what the rotation is from A to B. In other words:

A-to-B
= A-to-O * O-to-B
= R1^-1 * R2

[QUOTE=Dark Photon;1247257]I may be missing something, but think about it this way:

  1. You have a rotation R1 from a base orientation O to rotated orientation A (gold standard)
  2. You also have a rotation R2 from the base orientation O to a rotated orientation B

You want to find out what the rotation is from A to B. In other words:

A-to-B
= A-to-O * O-to-B
= R1^-1 * R2[/QUOTE]

I’m not sure I understand your response. R1 is a matrix? Because my rotation in 3D is either described by a quaternion or by a 3x3 matrix. I can’t quite see how your calculation will give me a measure (ideally a scalar) that indicates the amount of “mismatch”.

[QUOTE=Jubei;1247227]… find a measure of HOW MUCH they are mismatched…[/QUOTE] How about computing the angle between x and x’, y and y’, and z and z’, where x, y, and z are the rows of the target matrix, and x’, y’, z’ are the rows of the rotation matrix attempting to match the target matrix?

Well, I’m not sure exactly what you want to measure. If you compute the A-to-B transform as a matrix and run it through your favorite rot-matrix-to-unit-quaternion function, then you’ll have a quat that tells you by what angle they differ, and even about what axis to rotate to get it. (You could prob even do this with pure quats and it’d likely be cheaper).

Another option: take unit vectors A and B, and use the dot product to compute the angle. Cross to get the axis.

Since you just said rotation difference, I’m assuming there is no translation difference, or you don’t care about that.

The problem with that is that if I take the absolute value of sin(theta) or cosine(theta) on each individual axis, the sin(theta) for example might be very close even though the object is facing almost 2*pi degrees to the opposite direction. Then if I use degrees as a comparison I might get 180 degree difference on some axis even though the objects are almost matched (just because it has rotated around almost full circle).

So I don’t think comparing each individual axis works. At the end of the day I want to say "that user matched the rotation of the cursor to the target 90% or… 10% " depending on how close they matched it.

First of all let me say that I really appreciate the efforts to help.

Hmm… aren’t there many different combinations of axis angle to get to achieve a certain rotation? So if I get two quaternions for the two orientations I want to compare couldn’t it be that the angle magnitude is bigger but the unit axis a totally different one, as such the comparison would be meaningless? I might be missing something, please correct me if I’m wrong.

[QUOTE=Dark Photon;1247291]Another option: take unit vectors A and B, and use the dot product to compute the angle. Cross to get the axis.[/QUOTE]Which unit vectors would those be? Apologies in advance but I don’t understand.

Yes it’s unimportant, I’m already measuring this as the distance between the center of the objects’ bounding boxes.

No you don’t compare them directly. From them you’d composite them to compute a single transform which rotates from A to B (via matrices or directly). But seems simpler just to use the vector dot/cross I described next.

Related link:

Websearch “angle between two quaternions” for more.

Which unit vectors would those be? Apologies in advance but I don’t understand.

Envision a unit sphere. The center is your rotation origin (call it X). You have two rotation orientations, which correspond to 2 points on the sphere (unit vectors from the center – call them A and B). Sounds like you just want to know what the angle difference is between vectors XA and XB. No?
dot product, inverse cosine, and you’ve got the angle.

Thanks for the responses I will investigate further!