You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix overlapping branches in batch quaternion conversion - #400
One component comes from its square root, and the others are off-diagonal sums divided by it (e.g. $4xy = R_{10}+R_{01}$). Each matrix should take exactly one branch, chosen so that divisor is large. ind3 didn't exclude ind2, so when $\mathrm{tr},R \le 0$ and $R_{00} > R_{11} > R_{22}$ the y branch overwrote the x result. That divides by $4|y|$, taken from $1-R_{00}+R_{11}-R_{22}$, which cancels badly when the axis is close to x. For a half-turn about normalize(1, 2e-8, 0), $|q|$ comes out about 2% off.
With ind2 excluded, the x branch is used. There $x^2-y^2=(R_{00}-R_{11})/2\ge 0$, likewise for $z$, and $w^2\le 1/4$, so $x^2\ge 1/4$ and the divisor $4x$ is at least 2. This matches the if/elif in quaternion_from_matrix. In that region the output may now be $-q$ rather than $q$ ($x>0$ instead of $y\ge 0$), which is the same rotation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
quaternions_from_matricescould return a non-unit quaternion near an x-axis half-turn because the y branch overwrote the dominant x result.We exclude matrices already handled by the x branch from the y branch.
We've verified the regression and the full test suite.
Fixes #399
— ChipLab