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

Interpolation of rotation matrix doesn't quarantee orthonormality #138

Open
JoOkuma opened this issue Nov 10, 2022 · 1 comment
Open

Interpolation of rotation matrix doesn't quarantee orthonormality #138

JoOkuma opened this issue Nov 10, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@JoOkuma
Copy link
Contributor

JoOkuma commented Nov 10, 2022

Hi,

I noticed that when napari-animation interpolates the rotation matrix it deforms the data (changes its scale) because it doesn't guarantee the rotation matrix is orthonormal.

I think it should use something similar to the slerp interpolation of the camera.angles but in the matrix transform domain.

For example, when rotating this 3D image it's actually changing the scale on the z-axis.

video.mp4

Script to reproduce:

import napari
import numpy as np
from skimage import data
from napari_animation import Animation


if __name__ == "__main__":
    viewer = napari.view_image(data.cells3d(), channel_axis=1)

    animation = Animation(viewer)
    animation.capture_keyframe()

    R = np.diagflat([1, 1, -1])

    for l in viewer.layers:
        l.rotate = R

    viewer.reset_view()
    animation.capture_keyframe(127)
    animation.animate("video.mp4")

I can open a PR if this is agreed to be a bug.

@alisterburt
Copy link
Collaborator

alisterburt commented Nov 10, 2022

ooh this isn't good! thanks for the report

Definitely a bug, totally ready for a PR with a fix if you have one :-)

@psobolewskiPhD psobolewskiPhD added the bug Something isn't working label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants