Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rotation_matrix for opposite float32 vectors #3011

Merged
merged 4 commits into from
Mar 22, 2024

Conversation

jb-ye
Copy link
Collaborator

@jb-ye jb-ye commented Mar 20, 2024

When tensors a and b are float32, the condition c < -1 + 1e-8 will never be triggered because of round off tolerance being too small. Also I use a more principled implementation for computing the rotation matrix when a, b are opposite.

Test cases:

a=torch.rand(3, dtype=torch.float32)
b=-a
error=torch.norm(rotation_matrix(a, b) @ a[..., None] - b[..., None])

Copy link
Collaborator

@brentyi brentyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few minor changes:

  • Reformulating to return "exact" solutions without eps in the denominator
  • Renaming the function

If these makes sense to you @jb-ye the PR looks good to me 🙂

@jb-ye
Copy link
Collaborator Author

jb-ye commented Mar 21, 2024

@brentyi It looks good to me. Thanks for improving my PR.

@kerrj kerrj merged commit 12195f0 into nerfstudio-project:main Mar 22, 2024
2 checks passed
Michael-Spleenlab pushed a commit to Michael-Spleenlab/nerfstudio that referenced this pull request Apr 26, 2024
…3011)

* Fix rotation_matrix for opposite float32 vectors

* Reformulate rotation_matrix() without division => drop unnecessary `eps`

* Rename `rotation_matrix()` => `rotation_matrix_between()`

---------

Co-authored-by: Brent Yi <yibrenth@gmail.com>
Co-authored-by: Matias Turkulainen <30566358+maturk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants