sorry – I should know this but I don’t.
I have computed the position of a reference frame (S1) with respect to a base reference frame (S0) through two different processes that give me two different 4×4 affine transformation matrices. I’d like to compute an error between the two but am not sure how to deal with the rotational component. Would love any advice.
thank you!
You are looking for the single axis rotation from frame S1 to frame S0 (or vice versa). The axis of the rotation isn’t all that important here. You want the rotation angle.
Let R0 and R1 be the upper left 3×3 rotation matrices from your 4×4 matrices S0 and S1. Now compute E=R0*transpose(R1) (or transpose(R0)*R1; it doesn’t really matter which.)
Now calculate
I’ve left out some hairy details (and these details can bite you). In particular, the above is invalid for very large error angles (error > 90 degrees) and is imprecise for large error angles (angle > 45 degrees).
If you have a general-purpose function that extracts the single axis rotation from a matrix, use it. Or if you have a general-purpose function that extracts a quaternion from a matrix, use that. (Single axis rotation and quaternions are very closely related to one another).