I’m working on an AR app and I want to compare the rotations of two image markers, which are successfully being rendering into world space and I have their transforms. The two rotations are expected to be very similar on two axis and only majorly differ on a third axis.
What I’ve tired so far:
Using Quaternion.Angle
private float compare(Quaternion quatA, Quaternion quatB)
{
return Quaternion.Angle(quatA, quatB)
}
This nearly gives me exactly what I want, the angle matches my expectations except it never gives me negative angles so I can’t tell the difference between 90 degrees and -90 degrees (as an example)
private float compare(Quaternion quatA, Quaternion quatB)
{
return (quatA * quatB).eulerAngles.y;
}
This seems like it might work, but I’m not sure that the y-axis will always be the axis that I want. Also I’m not sure how to know if I should be doing quatB * quatA (since that operation is non-commutative for quaternions). Does anyone have any guidance? I’ve tried to search for this but wasn’t able to find any threads that seemed to quite match what I’m trying to do.