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

Add example showing a simple 360 degree rotation #164

Open
GenevieveBuckley opened this issue Apr 19, 2023 · 2 comments
Open

Add example showing a simple 360 degree rotation #164

GenevieveBuckley opened this issue Apr 19, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@GenevieveBuckley
Copy link
Contributor

I think it would be useful to add an example to the docs showing a simple 360 degree rotation. Ideally it should have a section at the beginning setting the camera zoom/angle/etc. (all the things people might want to adjust slightly for their own datasets).

Getting a nice even rotation speed is kind of hard to do manually, so I think this would be useful.

I wrote a script to do this pretty early on, I'll see if I can dig it out again. It wasn't hard to do, so it might be just as simple for someone to write another one.

@alisterburt
Copy link
Collaborator

this would be useful for sure!

It shouldn't be too hard to bodge together with some programatically generated keyframes and a button in the GUI to add those would be nice

the camera now exposes view_direction and up_direction - rotating the view direction vector around the up vector would work

something like

import numpy as np
from scipy.spatial.transform import Rotation as R

camera: napari.Camera
animation: Animation

angles = np.linspace(0, 360, num=5).reshape(5, 1)
rotation = R.from_rotvec(np.array(camera.up_direction) * angles, degrees=True)
rotated_view_directions = rotation.apply(camera.view_direction)

for direction in rotated_view_directions:
    camera.set_view_direction(direction, up_direction=camera.up_direction)
    animation.capture_keyframe()

@GenevieveBuckley
Copy link
Contributor Author

It shouldn't be too hard to bodge together with some programatically generated keyframes and a button in the GUI to add those would be nice

Yes, absolutely!

@psobolewskiPhD psobolewskiPhD added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants