OpenUSD icon indicating copy to clipboard operation
OpenUSD copied to clipboard

GfQuat types are missing GfIsClose

Open andrewkaufman opened this issue 1 year ago • 6 comments

Description of Issue

As mentioned in #wg-usd on ASWF slack https://academysoftwarefdn.slack.com/archives/C013Z5AMT7T/p1720807979342119?thread_ts=1720804075.436449&cid=C013Z5AMT7T, the various GfQuat types do not work with Gf.IsClose in python. Presumbly they don't have a c++ implementation either.

andrewkaufman avatar Jul 12 '24 21:07 andrewkaufman

That is correct. Deciding what "the right" comparison should be for two quaternions is can be context-sensitive, I think.

spiffmon avatar Jul 12 '24 22:07 spiffmon

Oh? Interesting. The context of the slack conversation is for a diffing tool. In that context, would an element wise comparision (as though it was a float4) not be correct?

andrewkaufman avatar Jul 12 '24 22:07 andrewkaufman

For a straight-up textual or "numdiff" differ, yes that would be sufficient. But if we provide a GfIsClose for quaternions, then someone might believe it's going to give them a reasonable answer about the angular distance between the two orientations, which a component-wise diff does not discriminate well.

spiffmon avatar Jul 12 '24 23:07 spiffmon

I was thinking that a reasonable GfIsClose might be

abs(1 - abs(q1 x q2*)) < eps

where x is a multiplication and * is the inverse. That would capture the case where two rotations are the same but have an opposite sense.

Removing the inner abs would reject two rotations that are the same but have an opposite sense.

I wonder if GfIsClose should try to say that two quarternions are close with the same sense. And we could document how to accomplish the other.

meshula avatar Jul 13 '24 01:07 meshula

Ps, I am suggesting the norm comparison rather than an element wise comparison because the elements of a quaternion are coupled, and the norm comparison will test the distribution of error about the sphere. A component wise comparison might report a lesser or greater difference but might represent a deviation from a norm based comparison. In other words the norm measure will capture a deviation from a unit length, and the component wise comparison will not.

meshula avatar Jul 13 '24 01:07 meshula

Filed as internal issue #USD-9843

jesschimein avatar Jul 15 '24 17:07 jesschimein