﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
2681	Pick nearest atom in VR	tic20@…	Tom Goddard	"From: Tristan Croll
Subject: A suggestion for VR interaction
Date: December 12, 2019 at 2:50:12 AM PST
To: Tom Goddard 

Hi Tom,

Just thinking about ways to make VR tugging as intuitive as possible... the number one complaint I had with my old haptic-based interactive MD was that it could be hard to tell exactly which atom was going to be grabbed. While I'm no longer supporting haptic devices in ISOLDE (for the time being at least - may revisit later, since they're still fun to play with), I took the following approach in year 1 of its development. The atom to be tugged was based on proximity to the tool tip rather than intersection of a ray with the drawing - I find this is much more robust when the atoms are jiggling around. I used the following code (which could probably be optimised given the simplicity of the task):

def pick_closest_to_point(session, xyz, atoms, cutoff, displayed_only = True, hydrogens = False):
   '''
   Pick the atom closest to an (x,y,z) point in scene coordinates. Optionally the
   selection can be limited to include only displayed atoms and/or
   exclude hydrogens.
   '''
   closest = None
   import numpy
   if displayed_only:
       atoms = atoms.filter(atoms.displays)
   if not hydrogens:
       atoms = atoms.filter(atoms.element_names != 'H')
   atomic_coords = atoms.scene_coords

   from chimerax.core.geometry import find_closest_points
   ignore1, ignore2, nearest = find_closest_points([xyz], atomic_coords, cutoff)
   if nearest is not None:
       if len(nearest):
           return atoms[nearest[0]]
   return

One could also perhaps consider looking for atoms within a cone projected from the tip - but that of course would add a bit of complexity to the code.

Additionally, it was *really* helpful to draw an indicator showing exactly which atom would be affected when you pressed the button. At the time I was just changing the radius and colour of the atom itself, which of course made things horribly slow (I was still coming to terms with the code-base and its conventions), but a simple coloured sphere drawn over the atom works great and would have minimal cost.

Best regards,

Tristan
"	enhancement	assigned	moderate		VR								all	ChimeraX
