nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
788 stars 132 forks source link

Visualizing arrows defined by atoms positions along a trajectory #1105

Open dpasserone opened 3 months ago

dpasserone commented 3 months ago

I am able to add arrows to an ASEstructure object, by connecting two atoms at positions c1 and c2.

  def view_structure(structure,myvec=[]):
          t = nv.ASEStructure(structure)
          w = nv.NGLWidget(t, gui=True)
          return w

  myview = view_structure(myase_structure)
  c1 = myase_structure.get_positions()[6]
  c2 = myase_structure.get_positions()[5]
  myview.shape.add_arrow(c1,c2,[0,0,0],0.3)
image

How can I do the same with the analogous ASETrajectory, making the arrow recalculating the c1 and c2 positions everytime I change the frame in the GUI?

def view_trajectory(trajectory):
    t2 = nv.ASETrajectory(trajectory)
    w2 = nv.NGLWidget(t2, gui=True)
    return w2;

Thank you!

hainm commented 3 months ago

hi @dpasserone Unfortunately I don't know the answer yet (not sure if it's possible).