View Full Version : 3D rotation mismatch calculation

Jubei

01-18-2013, 01:23 AM

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

Dark Photon

01-18-2013, 07:11 PM

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

Jubei

01-19-2013, 05:09 AM

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

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".

Carmine

01-19-2013, 02:05 PM

.... find a measure of HOW MUCH they are mismatched.. 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?

Dark Photon

01-20-2013, 07:14 PM

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".

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.

Jubei

01-20-2013, 07:32 PM

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?

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.

Jubei

01-20-2013, 07:45 PM

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

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).

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.

Another option: take unit vectors A and B, and use the dot product to compute the angle. Cross to get the axis.Which unit vectors would those be? Apologies in advance but I don't understand.

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

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

Dark Photon

01-21-2013, 05:56 AM

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?

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:

* http://www.gamedev.net/topic/423462-rotation-difference-between-two-quaternions/

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.

Jubei

01-29-2013, 08:08 PM

Thanks for the responses I will investigate further!

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.